-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: workflow to link pr to issue (#7)
- Loading branch information
1 parent
a831f16
commit 01778b9
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
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 }}" |