Skip to content

test_issue

test_issue #13

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
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."
gh issue close ${{ github.event.issue.number }}
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 }}