Skip to content

Commit 34a6ec1

Browse files
authored
Merge pull request #28 from OpenKetchupSource/feat/23
feat: PR이 닫힐 때 체크리스트가 완료된 경우 언급된 이슈 자동 닫기 기능 추가
2 parents 7f3a3f7 + 0118fd4 commit 34a6ec1

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/closed-issue.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Close Mentioned Issues if Checklist Complete
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: read
10+
contents: read
11+
12+
jobs:
13+
close-mentioned-issues:
14+
if: github.event.pull_request.merged == true
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check if checklist is fully complete
18+
id: checklist
19+
run: |
20+
BODY="${{ github.event.pull_request.body }}"
21+
UNCHECKED=$(echo "$BODY" | grep -c '\[ \]')
22+
if [ "$UNCHECKED" -eq 0 ]; then
23+
echo "checklist-complete=true" >> $GITHUB_OUTPUT
24+
else
25+
echo "checklist-complete=false" >> $GITHUB_OUTPUT
26+
fi
27+
28+
- name: Extract issue numbers
29+
id: issues
30+
run: |
31+
BODY="${{ github.event.pull_request.body }}"
32+
echo "ISSUES=$(echo "$BODY" | grep -oE '#[0-9]+' | tr -d '#' | tr '\n' ' ')" >> $GITHUB_OUTPUT
33+
34+
- name: Close mentioned issues
35+
if: steps.checklist.outputs.checklist-complete == 'true'
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
for issue in ${{ steps.issues.outputs.ISSUES }}; do
40+
gh issue close "$issue" --repo "${{ github.repository }}"
41+
done

0 commit comments

Comments
 (0)