Skip to content

ci: alias PR preview deployments to the PR number#57

Merged
swibrow merged 2 commits into
mainfrom
ci/pr-preview-alias
Jul 18, 2026
Merged

ci: alias PR preview deployments to the PR number#57
swibrow merged 2 commits into
mainfrom
ci/pr-preview-alias

Conversation

@swibrow

@swibrow swibrow commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add --preview-alias pr-<number> to the PR deploy command so repeated pushes to the same PR reuse one stable preview URL instead of minting a new Worker version (and URL) on every commit.

Context

Cloudflare doesn't expose an API or CLI to delete individual Worker versions (confirmed against the Workers Scripts Versions API and the beta Workers Versions API — both are list/get/create only, no delete), so this can't clean up existing orphaned preview versions, and merging/closing a PR still won't trigger any deletion. This just slows the rate new ones pile up.

Test plan

  • Open this PR itself and confirm the "Preview deployed" comment still posts with a working URL
  • Push a second commit to this branch and confirm the preview URL is reused rather than replaced with a new one

Cloudflare has no API or CLI to delete individual Worker versions, so
PR preview deployments can't be cleaned up on merge/close. Using
--preview-alias pins each PR to a stable, reused preview URL instead
of minting a brand new version+URL on every push, which at least
slows the buildup instead of one version per commit.
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

🚀 Preview deployed: https://pr-57-wibrow-dev.sam-wibrow.workers.dev

deployment-url is the per-commit version URL, which still changes on
every push even with --preview-alias set - the alias only shows up in
wrangler's text output as "Version Preview Alias URL". Parse it out of
command-output (via env, not string-interpolated into the script) so
the PR comment actually gets the stable, reused link.
@swibrow
swibrow merged commit d363e8b into main Jul 18, 2026
1 check passed
@swibrow
swibrow deleted the ci/pr-preview-alias branch July 18, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant