File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments