Chore: issue id in create branch script 12 #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: link pr to issue | |
on: | |
pull_request: | |
types: [opened, edited, reopened] | |
branch_protection_rule: | |
types: [edited] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
link-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Extract branch name | |
shell: bash | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
run: | | |
issue_id=$(echo ${{ env.BRANCH_NAME }} | grep -oE '[0-9]+$') | |
echo "issue_id=$issue_id" >> $GITHUB_ENV | |
- name: Check if Issue ID Exists | |
id: check | |
run: | | |
if [ -z "${{ env.issue_id }}" ]; then | |
echo "No issue ID found in branch name." | |
exit 1 | |
fi | |
- name: Update PR Description | |
if: steps.check.outcome == 'success' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh pr edit ${{ github.event.pull_request.number }} --body "$(cat << EOF | |
${{ github.event.pull_request.body }} | |
Closes #${{ env.issue_id }} | |
EOF | |
)" |