Add GitHub Actions CI: preview deployments and production deploy#1
Merged
maxwellpeterson merged 7 commits intomainfrom Mar 20, 2026
Merged
Add GitHub Actions CI: preview deployments and production deploy#1maxwellpeterson merged 7 commits intomainfrom
maxwellpeterson merged 7 commits intomainfrom
Conversation
…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.
Preview deploymenthttps://mpeterson-github-actions-ci-grangarda.archmap.workers.dev |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
preview.ymlworkflow that runsnpm run deploy:preview(wrangler preview) on every PR and posts a comment with the preview URL, updating it on subsequent pushesdeploy.ymlworkflow that runsnpm run deploy(wrangler deploy) on pushes tomainwranglerto the prerelease from cloudflare/workers-sdk#12983 which introduces thewrangler previewcommanddeploy:previewscript to callwrangler previewafter build; removes thepreview(vite preview) scriptSetup required
Add a
CLOUDFLARE_API_TOKENsecret to the repo:Settings → Secrets and variables → Actions → New repository secret