Repository navigation
Sweep stale Hosted previews at deploy instead of at close - #1346
Merged
Merged
Conversation
The close-time cleanup job ran in the approval-gated hosted-preview environment, so it waited for an approval nobody gave and never ran; ten merged PRs' previews leaked. Each preview deploy now first deletes the Workers, Hyperdrive, and Neon branch of every other PR that is closed or no longer labeled hosted-preview, and nothing runs at close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying mouseterm with
|
| Latest commit: |
e0adbdf
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7b4a6742.mouseterm.pages.dev |
| Branch Preview URL: | https://hosted-preview-sweep.mouseterm.pages.dev |
dormouse-bot
left a comment
Collaborator
There was a problem hiding this comment.
PRODUCTION_IDS / refuseProduction guards against a case nothing reachable produces, and it adds a spec rule (hosted.md -> "PR previews": Never let preview cleanup target production's Cloudflare account or Neon project) that must now be kept in sync by hand. Details inline.
This reverts commit fcb377d.
nedtwigg
marked this pull request as ready for review
October 21, 2026 20:28
nedtwigg
requested a deployment
to
hosted-preview
October 21, 2026 20:31 — with
GitHub Actions
Waiting
dormouse-bot
approved these changes
Oct 21, 2026
This branch is waiting to be 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.
The close-time
cleanupjob ran in the approval-gatedhosted-previewenvironment, so every run waited for an approval nobody gave, until the mass cancel on 2026-10-21. Ten merged PRs' previews leaked (#748, #812, #815, #836, #865, #872, #887, #888, #1044, #1104).The environment has to stay gated, because a
pull_requestjob runs the PR's own workflow file. So cleanup now runs inside the deploy, whose approval already covers the preview credentials:preview.mjs sweeplists the preview account's Workers and Hyperdrives and the preview project's Neon branches. It finds each*-pr-N, asks GitHub for that PR's state, and runscleanupfor every PR other than the deploy's own that is closed or no longer labeledhosted-preview.pull-requests: readfor the lookup.cleanupjob and theunlabeledandclosedtriggers are gone. A stale preview now lives until the next approved preview deploy.S69updated;hosted.md's word budget ratcheted 4550 → 4600.Labeling this PR
hosted-previewand approving its deploy removed the leaked previews (#812 never had one; it shares #815's branch).🤖 Generated with Claude Code