Skip to content

Add Cloudflare preview deployments for pull requests - #14

Merged
blindtechmage merged 1 commit into
mainfrom
ci/cloudflare-preview-deployments
Aug 13, 2026
Merged

Add Cloudflare preview deployments for pull requests#14
blindtechmage merged 1 commit into
mainfrom
ci/cloudflare-preview-deployments

Conversation

@blindtechmage

Copy link
Copy Markdown
Owner

Summary

  • Adds a Preview Deploy CI workflow that runs on every pull request (opened/synchronize/reopened) against main: builds the site, then uploads a new Worker version (wrangler versions upload, not wrangler deploy — this never touches the production/Active deployment) tagged with a stable pr-<number> preview alias, and posts (or updates, on later pushes to the same PR) the resulting preview URL as a PR comment.
  • Fixes a real, unrelated deploy blocker found along the way: @astrojs/cloudflare's built-in sessions feature auto-injects a SESSION KV binding into the generated wrangler.json, but it had no namespace ID — that's a hard failure at deploy time (KV namespace id is a required field), not something CI could work around. Provisioned a real KV namespace and added its ID to wrangler.toml. KV namespace IDs are not secret (see Cloudflare's docs), so this is safe to commit.
  • Uses the CLOUDFLARE_API_KEY repo secret (a scoped API token, Workers Scripts edit only on this account — despite the legacy-sounding name) and a new CLOUDFLARE_ACCOUNT_ID repo variable (not sensitive).

Closes #4

Notes

  • This is PR-preview only, not a production deploy-on-merge pipeline — that's a separate, not-yet-scoped backlog item.
  • Per the issue's acceptance criteria, runtime secrets not yet provisioned (e.g. RECAPTCHA_SECRET) don't block the preview: Workers secrets resolve at request time, not at version-upload time, so every route except the contact form's POST handler previews correctly regardless.
  • This can't be fully exercised until this very PR runs — the Deploy Cloudflare Preview check on this PR is itself the first real test of the workflow.

Test plan

  • npm run typecheck
  • npm run lint (js + markdown)
  • npm run build
  • npm run test:unit (26/26 passing)
  • npx wrangler versions upload --dry-run against the built config, locally, to confirm bindings resolve correctly
  • Workflow YAML validated with js-yaml
  • Live preview deploy on this PR (self-verifying — see the Deploy Cloudflare Preview check)

Adds a CI job that uploads a new Worker version (wrangler versions
upload, not a full deploy — never touches the production/Active
deployment) on every pull request, tagged with a stable per-PR preview
alias, and posts/updates the resulting preview URL as a PR comment.

Also provisions the SESSION KV namespace that @astrojs/cloudflare's
sessions feature auto-injects into the generated wrangler.json — it
previously had no namespace ID, which would have hard-failed any real
deploy regardless of this change (KV namespace IDs are not secret).

Closes #4

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@blindtechmage
blindtechmage merged commit d6debed into main Aug 13, 2026
5 of 6 checks passed
@blindtechmage
blindtechmage deleted the ci/cloudflare-preview-deployments branch August 13, 2026 01: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.

Set up Cloudflare preview deployments for pull requests

2 participants