Skip to content

Add GitHub Actions CI: preview deployments and production deploy#1

Merged
maxwellpeterson merged 7 commits intomainfrom
mpeterson/github-actions-ci
Mar 20, 2026
Merged

Add GitHub Actions CI: preview deployments and production deploy#1
maxwellpeterson merged 7 commits intomainfrom
mpeterson/github-actions-ci

Conversation

@maxwellpeterson
Copy link
Owner

Summary

  • Adds a preview.yml workflow that runs npm run deploy:preview (wrangler preview) on every PR and posts a comment with the preview URL, updating it on subsequent pushes
  • Adds a deploy.yml workflow that runs npm run deploy (wrangler deploy) on pushes to main
  • Updates wrangler to the prerelease from cloudflare/workers-sdk#12983 which introduces the wrangler preview command
  • Updates deploy:preview script to call wrangler preview after build; removes the preview (vite preview) script

Setup required

Add a CLOUDFLARE_API_TOKEN secret to the repo:
Settings → Secrets and variables → Actions → New repository secret

…eploy

- Add preview.yml: creates a Worker Preview on every PR using wrangler preview
  (prerelease from cloudflare/workers-sdk#12983), posts/updates a PR comment
  with the preview URL
- Add deploy.yml: runs npm run deploy on pushes to main
- Update wrangler to prerelease version from pkg.pr.new/wrangler@12983
- Replace deploy:preview script to call wrangler preview after build
- Remove vite preview script (superseded by wrangler preview)
npm ci rejects non-semver versions (URL-based installs), so the prerelease
wrangler must be installed after npm ci rather than declared in package.json.
The lockfile had URL-resolved entries for wrangler and its sub-deps from
the prerelease install, which caused npm ci to fail with 'Invalid Version'.
- Use set +e to prevent bash -e from aborting before we can echo output
- Run Post preview comment step with if: always() so it posts even on failure
…thub-script

- Remove if: always() so comment only posts on successful deploy
- Remove raw wrangler output interpolation into JS template literal which
  caused SyntaxError when output contained JS keywords
Wrangler fails in non-interactive mode when multiple accounts are
available and no account ID is specified.
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

GitHub Actions checks out PRs in detached HEAD state, causing
git rev-parse --abbrev-ref HEAD to return 'HEAD' -> slug 'head'.
Pass --name explicitly using github.head_ref instead.
@maxwellpeterson maxwellpeterson merged commit f2db95d into main Mar 20, 2026
1 check passed
@maxwellpeterson maxwellpeterson deleted the mpeterson/github-actions-ci branch March 20, 2026 23:20
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