blob: 67b3b77649377612d5b80c65bce84c5f74e57c85 [file]
name: "PR Metadata Checks"
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
- edited
jobs:
blocks-do-not-merge:
runs-on: ubuntu-latest
steps:
- name: Check for "do not merge" label
if: "contains(github.event.pull_request.labels.*.name, 'do not merge')"
run: |
echo "::error::This PR has the 'do not merge' label" \
"and cannot be merged."
exit 1
- name: Check PR description for DO NOT SUBMIT/MERGE
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
echo "Checking PR description..."
if printf '%s\n' "$PR_BODY" \
| grep --extended-regexp --ignore-case --quiet "DO NOT SUBMIT|DO NOT MERGE"; then
echo "::error::This PR description contains" \
"'DO NOT SUBMIT' or 'DO NOT MERGE'" \
"and cannot be merged."
exit 1
fi
echo "PR description is clean."
block-transient-agent-files:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: Check for blocked files
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_REPO: ${{ github.repository }}
run: |
echo "Checking for blocked files..."
# We use --repo to avoid needing actions/checkout.
# This keeps the job lightweight and avoids "not a git repository" errors.
changed_files=$(gh pr diff --name-only --repo "$GH_REPO" -- "$PR_NUMBER")
# grep exits 1 when no lines match, which is expected when no blocked files exist.
blocked_files=$(
printf '%s\n' "$changed_files" \
| grep --extended-regexp '^.agents/(plans|scratch)(/|$)' || true
)
if [ -n "$blocked_files" ]; then
echo "::error::Files in .agents/plans and" \
".agents/scratch are permitted in PRs to" \
"facilitate discussion, but are not allowed" \
"to be merged. Please remove them before merging:"
printf '%s\n' "$blocked_files"
exit 1
fi
echo "No blocked files found."