Skip to content

Commit

Permalink
Update close-on-merge.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
thestarsahil authored May 25, 2024
1 parent 42c4e91 commit 6490a79
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/close-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ jobs:
- name: Close linked issues
if: github.event.pull_request.merged == true
run: |
# Extract issue numbers from the PR body
ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#')
# Loop through each extracted issue number and close the issue
for ISSUE in $ISSUES
do
echo "Closing issue #$ISSUE"
# Post a comment to the issue indicating it was closed by the merged PR
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \
-d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}'
-d "{\"body\":\"Closed by PR #${{ github.event.pull_request.number }}\"}"
# Close the issue by updating its state to "closed"
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \
-d '{"state":"closed"}'
done
-d "{\"state\":\"closed\"}"
done

0 comments on commit 6490a79

Please sign in to comment.