feat: pr checklist #15
This file contains hidden or 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: Enforce Checklist | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize] | |
| jobs: | |
| check-checklist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v2 | |
| # Extract the PR body directly from the GitHub event payload | |
| - name: Validate Checklist | |
| run: | | |
| # Use jq to parse the pull_request body from the event payload | |
| PR_BODY=$(jq -r .pull_request.body "$GITHUB_EVENT_PATH") | |
| # 1. Check for "## Checklist" section | |
| if ! echo "$PR_BODY" | grep -q "^## Checklist"; then | |
| echo "No '## Checklist' section found in the PR description." | |
| exit 1 | |
| fi | |
| # 2. Check that there is at least one checkbox line | |
| CHECKBOX_COUNT=$(echo "$PR_BODY" | grep "^- \[" | wc -l) | |
| if [ "$CHECKBOX_COUNT" -eq 0 ]; then | |
| echo "No checklist items found under '## Checklist'." | |
| exit 1 | |
| fi | |
| # 3. Ensure all checkbox items are ticked | |
| UNCHECKED_COUNT=$(echo "$PR_BODY" | grep "^- \[ \]" | wc -l) | |
| if [ "$UNCHECKED_COUNT" -gt 0 ]; then | |
| echo "Not all checklist items are checked. Please tick all boxes." | |
| exit 1 | |
| fi | |
| echo "All checks passed. The checklist is present and fully checked." |