ci: opt in to checkout v7 fork guard in workflow_run apply jobs#1906
Conversation
actions/checkout v7 refuses to check out fork PR code from a workflow_run workflow unless the step explicitly sets allow-unsafe-pr-checkout: true. Since the v7 bump (emdash-cms#1611), every "Query Counts — Apply" and "Auto Format — Apply" run that reaches the fork checkout fails with "Refusing to check out fork pull request code", so fork PRs no longer get snapshot updates or auto-formatting pushed back. Both jobs were already designed for this trust boundary: they never execute code from the fork tree — they only apply inert artifacts produced by the trusted measure/format runs (JSON copies, git apply) and push with a scoped app token via GIT_ASKPASS, with persist-credentials: false. Opt in explicitly and document why the checkout is safe.
|
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
CI-only fix: correctly scoped and safe
This is a targeted CI workflow fix. It adds allow-unsafe-pr-checkout: true — plus explanatory comments — to the two workflow_run-triggered apply jobs that currently fail on fork PRs after the actions/checkout v7 bump.
Approach assessment
The approach is the right one. The v7 fork guard specifically blocks checking out fork PR code from workflow_run workflows unless you opt in. The two apply jobs genuinely need a checkout at the measured fork SHA so they can push the auto-generated commits back (style: format and ci: update query-count snapshots). They don't execute any code from the checked-out tree — auto-format-apply does git apply on a trusted artifact patch, and query-counts-apply only copies inert JSON files — and both already use persist-credentials: false with a scoped app token pushed via GIT_ASKPASS.
I checked for other workflows that might need the same treatment. format-command.yml also has a "Checkout (fork)" step using checkout v7, but it is triggered by issue_comment (not workflow_run) and it actually runs tooling over the checked-out tree, so it is outside the scope of this fix. No other workflow has both workflow_run and a fork checkout step.
Code-level review
- YAML syntax and indentation are correct;
allow-unsafe-pr-checkout: trueis at the proper level inside thewith:map. - Comments accurately describe what the subsequent steps do and why the opt-in is safe.
persist-credentials: falseremains in place above the new opt-in.- Input name matches the one documented in the checkout action's error message.
This is a clean, narrowly scoped CI repair with no production code or user-facing changes.
…sh-cms#1906) actions/checkout v7 refuses to check out fork PR code from a workflow_run workflow unless the step explicitly sets allow-unsafe-pr-checkout: true. Since the v7 bump (emdash-cms#1611), every "Query Counts — Apply" and "Auto Format — Apply" run that reaches the fork checkout fails with "Refusing to check out fork pull request code", so fork PRs no longer get snapshot updates or auto-formatting pushed back. Both jobs were already designed for this trust boundary: they never execute code from the fork tree — they only apply inert artifacts produced by the trusted measure/format runs (JSON copies, git apply) and push with a scoped app token via GIT_ASKPASS, with persist-credentials: false. Opt in explicitly and document why the checkout is safe.
What does this PR do?
Repairs the
Query Counts — ApplyandAuto Format — Applyworkflows for fork PRs. Since theactions/checkoutv7 bump (#1611), checkout refuses to fetch fork PR code from aworkflow_runworkflow unless the step explicitly opts in withallow-unsafe-pr-checkout: true. Every apply run that actually reaches theCheckout (fork)step now fails with:Example failing runs: 29079049235 (PR #1905), 29074697406. The recent "successful" runs only succeeded because they skipped both checkout steps (no artifact to apply) — so fork PRs currently never get snapshot updates or auto-formatting pushed back.
The opt-in matches the trust design these workflows already document (from the #1638 hardening): after the fork checkout, no code from the fork tree is executed — the jobs only copy the inert snapshot JSONs /
git applythe patch from the trusted measure/format artifact, thengit add/commit/pushwith a scoped app token supplied viaGIT_ASKPASS, withpersist-credentials: falseon the checkout. This PR addsallow-unsafe-pr-checkout: trueto the two fork checkout steps plus a comment explaining why the checkout is safe, so the reviewed rationale lives next to the opt-in.Closes #
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
Failure signature from the linked runs: