Repository navigation
fix(ci): run cleanup-previews on workflow_run so fork PRs get a write token - #4674
Merged
Merged
Conversation
potatowagon
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
August 3, 2026 08:42
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
approved these changes
Aug 3, 2026
cixzhang
enabled auto-merge (squash)
August 3, 2026 09:27
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the
Cleanup Preview Deploymentsworkflow, which403'd on thegh-pagespush for every fork PR.Closes #4672.
Why
The workflow triggered on
pull_request: [closed]. For PRs from a fork, GitHub hands the workflow a read-onlyGITHUB_TOKENregardless of thepermissions: contents: writedeclaration (the declaration is a ceiling, not a grant), sogit push origin gh-pageswas denied:Evidence: 22/22 recent cleanup failures were fork PRs; 0 same-repo runs failed. Two same-day runs deleting identical work (both
Summary: 1 items deleted) — the only variable was fork vs. same-repo:potatowagon/astryx) → cleanup run 30784441287 → 403 denied ❌The retry loop made it worse: it treated the
403as a[rejected] (fetch first)race and burned all 5 attempts behind a misleading "concurrent gh-pages update" message.How
workflow_run(CI completed) instead ofpull_request— same migrationdeploy-preview.ymlalready did for the exact same reason.workflow_runruns from the base repo with the repo's own write token, so cleanup works for fork PRs too. The dailyschedulecron andworkflow_dispatchare kept.closedevent: it reconciles on-diskpr/dirs against the live open-PR list (gh pr list) every run, so firing on any PR's CI completion is sufficient to GC closed/merged previews.if:guard so onlypull_request-triggered CI runs react (matchesdeploy-preview.yml); scheduled/manual runs always proceed.403/permission denial in the push-retry loop instead of retrying 5× — retrying can never fix a permissions cap. Genuine fetch-first races still retry as before.Safety
No change to what the job touches — it still only checks out
gh-pagesand deletes stale paths. It never checks out or runs PR-controlled code.Testing
set -eo pipefail(GitHub's bash default): a403output is detected and fast-aborts with the real cause; a fetch-first rejection falls through to retry.