Skip to content

ci: add Worker Previews alongside Workers for Platforms previews - #34369

Merged
mvvmm merged 8 commits into
productionfrom
ci/worker-previews-gh-actions
Oct 15, 2026
Merged

mvvmm merged 8 commits into
productionfrom
ci/worker-previews-gh-actions

Conversation

@mvvmm

@mvvmm mvvmm commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds Worker Previews to PR CI, next to the existing Workers for Platforms (dispatch namespace) previews. Nothing is removed; both run on every same-repo PR.

  • New publish-worker-preview job runs in parallel with publish-preview. It runs wrangler preview --config wrangler.preview.json on the cloudflare-docs Worker.

  • The job fails CI if the Worker Preview deploy fails. Only the final comment-posting step is continue-on-error.

  • Preview name is gh-<branch-slug>, so it never collides with the Previews Workers Builds creates from the bare branch slug on the same *.previews.developers.cloudflare.com domain.

  • URLs come from wrangler's JSON output (WRANGLER_OUTPUT_FILE_PATH), not hand-built.

  • Each preview posts its own PR comment from its own script, found by its own marker line:

    Preview Script Marker
    Workers for Platforms post-preview-url-comment/index.ts **Preview URL:**
    Worker Previews post-preview-url-comment/worker-preview.ts **Worker Preview URL:**

    Both comments include a changed-files table linking to their own host. Shared logic lives in shared.ts.

  • New preview-cleanup.yml deletes the gh- Preview when a PR closes.

  • bin/preview-name.ts is shared by the deploy and cleanup workflows so both always target the same name. It strips a leading gh- from the branch, caps the name at 63 characters (DNS label limit) and has unit tests.

Notes:

  • Both sources count toward the Worker's Previews-per-Worker limit.
  • wrangler.preview.json already has the previews block with MIDDLECACHE, so these Previews get that binding.
  • Not verified until the first CI run on this PR: whether CLOUDFLARE_API_TOKEN can create Previews on cloudflare-docs.

@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

AI Review

✅ Reviewed 39ce8e4 · 0 findings · incremental

Commands
  • /review Run a review now.
  • /full-review Review the entire PR diff.
  • /disable-auto-review Stop automatic reviews.
  • /rebase Rebase against production.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://ci-worker-previews-gh-actions.previews.developers.cloudflare.com (commit 39ce8e4)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f15c4407.previews.developers.cloudflare.com 39ce8e4 2026-10-15T20:40:23.908Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://57c8c212.previews.developers.cloudflare.com 3af5ba3 2026-10-15T19:59:29.233Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://deb0813b.previews.developers.cloudflare.com bb6e34b 2026-10-15T19:24:09.412Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://343cef13.previews.developers.cloudflare.com ca25698 2026-10-15T18:11:12.411Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://fa570995.previews.developers.cloudflare.com 4c2c8ce 2026-10-15T17:25:31.579Z Visit the dashboard ↗
  • Build: In progress 🔵

View logs ↗
88db750 2026-10-15T17:05:41.345Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://0a7bed1d.previews.developers.cloudflare.com 7517e98 2026-10-15T16:54:22.892Z Visit the dashboard ↗

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

@mvvmm

mvvmm commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

/bonk please review

@mvvmm
mvvmm requested a review from a team as a code owner October 15, 2026 17:44
@ask-bonk

ask-bonk Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Review: 1 finding.

Posted 1 inline finding on bin/preview-name.ts:26: previewName can return the same label for distinct branches once truncation applies (e.g. previewName("a".repeat(59)) == previewName("a".repeat(59) + "/b"), and "a".repeat(61) == "a".repeat(62)), so two PRs could overwrite the same gh- Preview — the same collision class the PR's 4c2c8ced fix addressed for short names. Suggest a short hash suffix when truncating.

github run

@cloudflare cloudflare deleted a comment from ask-bonk Bot Oct 15, 2026
Comment thread bin/post-preview-url-comment/index.node.test.ts Outdated
Comment thread bin/preview-name.ts Outdated
Comment thread bin/preview-name.ts Outdated
Comment thread bin/preview-name.ts Outdated
Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml
@mvvmm
mvvmm force-pushed the ci/worker-previews-gh-actions branch from 3af5ba3 to 39ce8e4 Compare October 15, 2026 20:29
@mvvmm
mvvmm added this pull request to the merge queue Oct 15, 2026
Merged via the queue into production with commit a5d7e03 Oct 15, 2026
15 checks passed
@mvvmm
mvvmm deleted the ci/worker-previews-gh-actions branch October 15, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants