test_issue2 #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Close Issue when all tasks are completed | |
on: | |
issue_comment: | |
types: [created, edited] | |
issues: | |
types: [opened, edited] | |
jobs: | |
check-tasks-and-close-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check if all tasks are completed and close issue | |
id: check-tasks | |
run: | | |
ISSUE_BODY="${{ github.event.issue.body }}" | |
CHECKBOX_TOTAL=$(echo "$ISSUE_BODY" | grep -o "\- \[\( \)\|\(x\)\]" | wc -l) | |
CHECKBOX_COMPLETED=$(echo "$ISSUE_BODY" | grep -o "\- \[x\]" | wc -l) | |
if [ "$CHECKBOX_TOTAL" -ne "0" ] && [ "$CHECKBOX_TOTAL" -eq "$CHECKBOX_COMPLETED" ]; then | |
echo "All tasks are completed. Closing issue." | |
echo "Issue Number: ${{ github.event.issue.number }}" | |
echo "Issue Body: ${{ github.event.issue.body }}" | |
echo "::set-output name=should_close::true" | |
elif [ "$CHECKBOX_TOTAL" -eq "0" ]; then | |
echo "No tasks found. Skipping." | |
else | |
echo "Not all tasks are completed. Skipping." | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 이 부분은 별도의 스텝으로 추가합니다. | |
- name: Close issue | |
if: steps.check-tasks.outputs.should_close == 'true' | |
uses: peter-evans/close-issue@v1 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
token: ${{ secrets.GITHUB_TOKEN }} |