This PR switches four lightweight workflows from `pull_request` to `pull_request_target` to stop GitHub from requiring manual approval when the `mathlib-lean-pr-testing[bot]` app triggers label events (e.g. adding `builds-mathlib`). Since the bot never lands commits on master, it is perpetually treated as a "first-time contributor" and every `pull_request` event it triggers requires approval. `pull_request_target` events always run without approval because they execute trusted code from the base branch. This is safe for all four workflows because none check out or execute code from the PR branch — they only read labels, PR body, and file lists from the event payload and API: - `awaiting-mathlib.yml` — checks label combinations - `awaiting-manual.yml` — checks label combinations - `pr-body.yml` — checks PR body formatting - `check-stdlib-flags.yml` — checks if stdlib_flags.h was modified via API Also adds explicit `permissions: pull-requests: read` to each workflow as a least-privilege hardening measure, since `pull_request_target` has access to secrets. Addresses the issue reported by Sebastian: https://lean-fro.zulipchat.com/#narrow/channel/398861-general/topic/mathlib.20pr-testing.20breakage.3F/near/575084348 🤖 Prepared with Claude Code --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
1.3 KiB
YAML
31 lines
1.3 KiB
YAML
name: Check PR body for changelog convention
|
|
|
|
on:
|
|
merge_group:
|
|
pull_request_target:
|
|
types: [opened, synchronize, reopened, edited, labeled, converted_to_draft, ready_for_review]
|
|
|
|
permissions:
|
|
pull-requests: read
|
|
|
|
jobs:
|
|
check-pr-body:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check PR body
|
|
if: github.event_name == 'pull_request_target'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
# Safety note: this uses pull_request_target, so the workflow has elevated privileges.
|
|
# The PR title and body are only used in regex tests (read-only string matching),
|
|
# never interpolated into shell commands, eval'd, or written to GITHUB_ENV/GITHUB_OUTPUT.
|
|
script: |
|
|
const { title, body, labels, draft } = context.payload.pull_request;
|
|
if (!draft && /^(feat|fix):/.test(title) && !labels.some(label => label.name == "changelog-no")) {
|
|
if (!labels.some(label => label.name.startsWith("changelog-"))) {
|
|
core.setFailed('feat/fix PR must have a `changelog-*` label');
|
|
}
|
|
if (!/^This PR [^<]/.test(body)) {
|
|
core.setFailed('feat/fix PR must have changelog summary starting with "This PR ..." as first line.');
|
|
}
|
|
}
|