Skip to content

Commit

Permalink
created close-on-merge.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Asymtode712 authored May 21, 2024
1 parent 0d19c20 commit 17511de
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/close-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Close Issues on PR Merge

on:
pull_request:
types: [closed]

jobs:
close-issues:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Close linked issues
if: github.event.pull_request.merged == true
run: |
ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#')
for ISSUE in $ISSUES
do
echo "Closing issue #$ISSUE"
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 }}"}'
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

0 comments on commit 17511de

Please sign in to comment.