Skip to content

Commit

Permalink
chore: workflow to link pr to issue (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashsongara101 authored Aug 16, 2024
1 parent a831f16 commit 01778b9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflow/link-pr-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Link PR to Issue

on:
pull_request:
types: [opened, edited]

jobs:
link-issue:
runs-on: ubuntu-latest
steps:
- name: Extract Issue ID from PR Title
id: extract
run: |
issue_id=$(echo ${{ github.event.pull_request.title }} | grep -oP '\(\K[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 PR title."
exit 1
fi
- name: Update PR Description
if: steps.check.outcome == 'success'
run: |
gh pr edit ${{ github.event.pull_request.number }} --body "${{ github.event.pull_request.body }}\nCloses #${{ env.issue_id }}"

0 comments on commit 01778b9

Please sign in to comment.