Skip to content

Commit

Permalink
Ensure PR checklist has been completed
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Dec 23, 2024
1 parent 3135635 commit 03971b9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/scripts/pr-check-checklist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e

echo "Fetching description..."
PR_BODY=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"$PR_URL" | jq -r '.body')

echo "Validating checklist..."
CHECKBOXES=$(echo "$PR_BODY" | grep -o '\[.\]')
UNCHECKED=$(echo "$CHECKBOXES" | grep '\[ \]' || true)

if [ -n "$UNCHECKED" ]; then
echo "❌ Checklist has not been completed"
exit 1
else
echo "✅ Checked Checklist, all checks checked and checked"
fi
20 changes: 20 additions & 0 deletions .github/workflows/valid-pr-description.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Validate Pull Request Description

on:
pull_request:
types: [opened, edited, synchronize]

jobs:
validate-description:
name: Validate Description
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Validate checklist has been completed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.url }}
run: ./.github/workflows/scripts/pr-check-checklist.sh

0 comments on commit 03971b9

Please sign in to comment.