ci(preview): isolate preview deploys per PR (fix shared-URL overwrite)#262
Merged
Conversation
Previously every PR ran `wrangler deploy --env preview`, which deploys to the single `wingdex-app-preview` Worker. Concurrent PRs overwrote each other at the same shared URL (wingdex-app-preview.lianguanlun.workers.dev) and shared the preview D1 + R2 state, so 'the preview' reflected whichever PR deployed last. Switch to per-PR aliased preview URLs: - `wrangler versions upload --env preview --preview-alias pr-<N>` creates a version with a stable alias URL pr-<N>-wingdex-app-preview.<subdomain>.workers.dev (requires preview_urls = true, already set). Unlike `deploy`, it does not change the live deployed version. - The deployment status + a sticky PR comment surface the per-PR URL, parsed from wrangler's output with a deterministic fallback. Each in-flight PR now has an isolated preview that no longer stomps the others.
Contributor
|
🔎 Preview for this PR: https://pr-262-wingdex-app-preview.lianguanlun.workers.dev Isolated per-PR alias, no longer shared/overwritten across PRs. Updates on every push. |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the CI preview deployment flow to prevent concurrent pull requests from overwriting a single shared Cloudflare Workers preview URL, restoring per-PR preview isolation after the Pages → Workers migration.
Changes:
- Switch preview deployment from
wrangler deploy --env previewtowrangler versions upload --env preview --preview-alias pr-<PR#>to create stable per-PR alias URLs. - Parse the per-PR alias URL from Wrangler output (with a deterministic fallback) and publish it via GitHub deployment status.
- Add/update a sticky PR comment containing the per-PR preview URL for reviewer convenience.
- Replace em-dashes with ASCII punctuation (CONTRIBUTING.md style guide) in the workflow comment and the sticky PR-comment body. - Paginate listComments via github.paginate so the sticky preview-URL marker is found on busy PRs instead of creating a duplicate comment.
The Branch preview deployment step set core.setOutput('preview_url', ...) but
nothing consumed it (the sticky-comment step re-parses the URL independently).
Remove the dead output to avoid confusion.
jlian
added a commit
that referenced
this pull request
Jul 21, 2026
) Follow-up to #262. Two cleanups + address the Node 20 deprecation notices. ## 1. Remove the preview sticky-comment step The `Comment preview URL on PR` step auto-posted (and re-posted on every push) a comment like [this one](#262 (comment)). It's redundant: the per-PR preview URL is already surfaced on the PR via the **GitHub deployment / Environments UI** (the `Branch preview deployment` step sets `environment_url`). Removing the comment cuts the noise. Also drops the now-unused `pull-requests: write` permission from the CI job (least privilege). ## 2. Fix Node 20 deprecation warnings CI was emitting: > Node 20 is being deprecated. This workflow is running with Node 24 by default... Source: actions still pinned to Node 20 runtimes. Bumped to Node 24: - `cloudflare/wrangler-action@v3` → `@v4` (ci.yml, release.yml). v4's only major change is `wranglerVersion` input flexibility (version ranges/tags); no behavior change for our exact-command usage. - `actions/github-script@v7` → `@v9` (ci.yml, cleanup-preview.yml, rotate-apple-secret.yml). v9 runs on node24. All other actions (`checkout@v6`, `setup-node@v6`, `cache@v5`) were already on Node 24. ## Verification - All 9 workflow files validated as parseable YAML. - No `@v3` wrangler-action / `@v7` github-script references remain. - Preview isolation (from #262) is unchanged: still `versions upload --preview-alias pr-<N>`. _Note: separately, the Copilot review comments on #259 are being handled on that PR._
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.
Problem
After the Pages → Workers migration, every PR overwrites the same preview deployment.
The CI deploy step ran
wrangler deploy --env preview, which always targets the single Worker namedwingdex-app-preview(from[env.preview]+ top-levelname = "wingdex-app"). So all open PRs deploy to the same URL —wingdex-app-preview.lianguanlun.workers.dev— and last-deploy-wins. They also shared the preview D1 (wingdex-db-dev) and R2 buckets, so "the preview" reflected whichever PR deployed most recently, not the PR you were looking at.Pages used to give per-branch preview URLs for free; the migration silently dropped that isolation.
Fix
Use per-PR aliased preview URLs:
wrangler versions upload --env preview --preview-alias pr-<PR#>. This creates a version with a stable alias URL of the formpr-<PR#>-wingdex-app-preview.<subdomain>.workers.dev(needspreview_urls = true, already set). Unlikedeploy, it does not change the live/deployed version — each PR only gets its own isolated preview URL.Result
pr-258-wingdex-app-preview...pr-259-wingdex-app-preview...pr-<n>-wingdex-app-preview...No more stomping. Each in-flight PR has an independent preview.
Notes / caveats
wingdex-db-devand thewingdex-range-priors/wingdex-modelsR2 buckets (these bindings are account-global). This PR isolates the code/URL, not the data. Fully isolating per-PR D1/R2 is a bigger change; flagging it but out of scope here.pr-<N>alias reuses it, and old versions age out per Cloudflare retention. The existingcleanup-preview.yml(deactivates GitHub deployment records on PR close) is unchanged.release.ymlon merge tomain, not this step.Priority: merge first, then the two in-flight PRs (#258, #259) get correct isolated previews once rebased/updated onto this.