Skip to content

Add PR preview builds with Cloudflare preview URLs - #21

Open
stu-greenshoots wants to merge 1 commit into
mainfrom
ci/pr-preview-workflow
Open

Add PR preview builds with Cloudflare preview URLs#21
stu-greenshoots wants to merge 1 commit into
mainfrom
ci/pr-preview-workflow

Conversation

@stu-greenshoots

Copy link
Copy Markdown
Member

What

Adds .github/workflows/pr-preview.yml: every PR against main now gets

  1. an astro build check (the repo previously had no CI on PRs at all), and
  2. a preview deployment — the built site is uploaded to Cloudflare as a Worker version via wrangler versions upload (production traffic is untouched), and a sticky PR comment links the *.workers.dev preview URL.

Why

Workers Builds deploys main to production but reports nothing back to GitHub — no checks, no statuses, no comments (verified on #18 and #20) — so there was no way to preview a PR from GitHub. PR #16 additionally recommends disabling Workers Builds for non-production branches; with this workflow, previews come from Actions instead, so that recommendation can be actioned without losing anything.

Setup required before this works

Two repository secrets (Settings → Secrets and variables → Actions):

  • CLOUDFLARE_API_TOKEN — token with Workers Scripts: Edit on the OpenDialog account
  • CLOUDFLARE_ACCOUNT_ID — the account id

Until they exist (and on fork/Dependabot PRs, which cannot read secrets), the workflow still runs the build as a check and skips the upload with a note in the job summary — no red X.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HVg4d3Fg3MLk6MEyjeYowp

Workers Builds deploys main to production but reports nothing back to
GitHub, so PRs had no build check and no preview. This workflow builds
every PR, uploads the result as a Worker version (production untouched)
and posts a sticky comment with the preview URL. Without the Cloudflare
secrets the build still runs as a check and the upload is skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVg4d3Fg3MLk6MEyjeYowp
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