Skip to content

Commit

Permalink
Merge pull request #12931 from richard-cox/pr-description
Browse files Browse the repository at this point in the history
Add PR gate to ensure checklist has been completed
  • Loading branch information
richard-cox authored Jan 6, 2025
2 parents 85b097b + 03971b9 commit 516a6ff
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 516a6ff

Please sign in to comment.