Skip to content

Commit 41ecf97

Browse files
authored
Merge pull request #114 from Asymtode712/CloseOnMerFeat
created close-on-merge.yml
2 parents ce89f5b + 961583d commit 41ecf97

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/close-on-merge.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Close Issues on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
close-issues:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v2
14+
15+
- name: Close linked issues
16+
if: github.event.pull_request.merged == true
17+
run: |
18+
ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#')
19+
for ISSUE in $ISSUES
20+
do
21+
echo "Closing issue #$ISSUE"
22+
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
23+
-H "Accept: application/vnd.github.v3+json" \
24+
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \
25+
-d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}'
26+
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
27+
-H "Accept: application/vnd.github.v3+json" \
28+
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \
29+
-d '{"state":"closed"}'
30+
done

0 commit comments

Comments
 (0)