-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pr issue close workflow μμ± (#328)
- Loading branch information
Showing
1 changed file
with
33 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,33 @@ | ||
name: Close Issue on PR Merge | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
close-issue: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Extract issue number from PR body | ||
id: extract_issue | ||
run: | | ||
# Fetch PR body | ||
PR_BODY=$(curl -s -H "Authorization: token ${{ secrets.CONFIG_SUBMODULE_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}" \ | ||
| jq -r '.body') | ||
# Extract issue number from PR body using regex (customize if needed) | ||
ISSUE_NUMBER=$(echo "$PR_BODY" | grep -oP '#\d+' | head -1 | sed 's/#//') | ||
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV | ||
- name: Close associated issue | ||
if: env.ISSUE_NUMBER != '' | ||
run: | | ||
echo "Closing issue #${{ env.ISSUE_NUMBER }}" | ||
curl -s -X PATCH -H "Authorization: token ${{ secrets.CONFIG_SUBMODULE_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-d '{"state": "closed"}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ env.ISSUE_NUMBER }}" |