Skip to content

fix(ci): stop the build command from deploying to production - #19

Merged
Aswinmcw merged 1 commit into
mainfrom
fix/build-command-cannot-deploy
Aug 14, 2026
Merged

fix(ci): stop the build command from deploying to production#19
Aswinmcw merged 1 commit into
mainfrom
fix/build-command-cannot-deploy

Conversation

@Aswinmcw

Copy link
Copy Markdown
Member

The problem

Cloudflare Workers Builds runs npm run deploy:web as its build command, on every branch. That script was:

opennextjs-cloudflare build && opennextjs-cloudflare deploy

It ends in a production deploy. The trigger it runs under is "Deploy non-production branches" (branch_excludes: ['main']), so a push to any branch shipped that branch to the production web worker — before review, before merge.

Not theoretical. From the #8 branch on 2026-07-27, and twice today from throwaway verification branches:

Executing user build command: npm run deploy:web
Uploaded shiptrack (6.20 sec)
Deployed shiptrack triggers (0.48 sec)     <- production
Current Version ID: 0e993497-...
Executing user deploy command: npx wrangler versions upload
Version Preview URL: https://14b59472-shiptrack.aswincloud.workers.dev   <- what it should have done alone

Today's two were harmless only because those branches were byte-identical to main. Until #8 landed, these builds died early at npm ci on the eslint 10 / eslint-config-next 15 peer conflict, which masked the behaviour — that guard is now gone, and five open dependabot PRs are the likely next trigger (#9 would put Next 16 on production).

The fix

Deploying is the trigger's own job, and it already does it correctly:

branch build command deploy command
main npm run deploy:web npx wrangler deploy
any other npm run deploy:web npx wrangler versions upload (preview, no traffic)

So the build command only needs to build:

  • new build:web = opennextjs-cloudflare build
  • deploy:web = npm run build:web — builds, never deploys
  • deploy = build + opennextjs-cloudflare deploy + poller, so a manual full deploy is unchanged
  • preview routed through build:web

The misleading deploy:web name is kept on purpose: the trigger config names it, and that config lives in the Cloudflare dashboard, not this repo. A "//deploy:web" note in package.json and a README table explain why, so the next person doesn't "fix" it by making it deploy again.

Side effect: main was deploying twice per merge (build command and deploy command). Now once.

Verification

production deployments before : 10  (latest 2026-08-14T10:37:26)
npm run deploy:web            : exit 0, .open-next/worker.js written, 0 deploy markers in output
production deployments after  : 10  (latest 2026-08-14T10:37:26)  <- unchanged
npx wrangler deploy --dry-run : Total Upload 5880.40 KiB          <- main still ships
npx wrangler deploy --dry-run -c wrangler.poller.jsonc : 49.51 KiB <- poller unaffected

Watch this PR's own build: it should log a Version Preview URL and no "Deployed shiptrack triggers" line. That's the fix demonstrating itself.

Still outstanding (dashboard-only, not fixable from the repo)

The poller's "Deploy non-production branches" trigger has deploy command npx wrangler versions upload, missing -c wrangler.poller.jsonc. Without the flag wrangler reads wrangler.jsonc (the web config) and fails on .open-next/worker.js, which the poller's npm install build never generates. That is the red X on the poller for every PR. It is cosmetic — the poller's default-branch trigger deploys correctly on every merge to main — but it needs the trigger's deploy command changed to:

npx wrangler versions upload -c wrangler.poller.jsonc

Trigger cfc489bb-f59e-4f71-a98b-6861180223fc, script b5a6adaa33b44418adbb02188e63f879.

Cloudflare Workers Builds runs `npm run deploy:web` as its BUILD command on
every branch, and that script ended in `opennextjs-cloudflare deploy`. So a
push to any branch deployed that branch to the production web worker, before
review and before merge.

This is not theoretical. It fired on 2026-07-27 from the #8 branch, and twice
today from throwaway verification branches — each logged "Deployed shiptrack
triggers" against the production URL. Until #8 landed, these builds happened
to die at `npm ci` on the eslint 10 / eslint-config-next 15 peer conflict,
which masked it; that guard is now gone.

Deploying is the trigger's own job and it already does it correctly:
`wrangler deploy` on main, `wrangler versions upload` (preview, no traffic)
elsewhere. The build command only needs to build. So `deploy:web` now just
builds, via a new `build:web`, and `npm run deploy` keeps doing a real manual
deploy of both workers.

The misleading `deploy:web` name is kept deliberately — the trigger config
names it, and that config lives in the Cloudflare dashboard, not this repo.
A "//deploy:web" note in package.json and a README table explain why, so the
next person doesn't help by making it deploy again.

Side effect: main deployed twice per merge (build command + deploy command).
Now once.

Verified: `npm run deploy:web` produces .open-next/worker.js and leaves the
production deployment count untouched at 10; `wrangler deploy --dry-run`
still resolves the entry point (5880 KiB), so main still ships; poller
dry-run unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Aswinmcw
Aswinmcw requested review from a team and Aswin-coder as code owners August 14, 2026 10:48

@Aswincloud-Bot Aswincloud-Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: @Aswinmcw is a member of @Aswincloud/admins.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shiptrack 1b9e3be Commit Preview URL

Branch Preview URL
Aug 14 2026, 10:50 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
shiptrack-poller 1b9e3be Aug 14 2026, 10:50 AM

@Aswinmcw
Aswinmcw added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit 6457bb7 Aug 14, 2026
5 of 6 checks passed
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.

3 participants