@@ -6,37 +6,32 @@ This app deploys through Cloudflare Workers Builds. The Cloudflare dashboard run
66
77## Build Variables
88
9- Set these build secrets in the Cloudflare Workers Builds settings :
9+ Set ` CONVEX_DEPLOY_KEY ` separately in ** Settings > Builds > Variables and secrets ** :
1010
11- - ` CONVEX_DEPLOY_KEY `
12- - ` PREVIEW_CONVEX_DEPLOY_KEY `
11+ - Production: a Convex production deploy key.
12+ - Previews Base: the Convex project's Preview deploy key.
13+
14+ These are build secrets. Previews Base runtime variables and secrets are Worker bindings, so they
15+ are not the place for a Convex deploy key. Samebase puts ` SAMEBASE_CONVEX_PROJECT ` , its project
16+ identity marker, in production build variables only.
1317
1418Do not add ` VITE_CONVEX_URL ` . Convex supplies the selected deployment URL to the frontend command
1519that runs through ` convex deploy --cmd ` .
1620
17- Cloudflare Workers Builds has separate production and preview build triggers
18- under the hood, but the dashboard currently shows one build-variable table. To
19- keep dashboard and API-created configurations equivalent, store both secrets on
20- both triggers. This also keeps the production and preview keys visible in the
21- dashboard. Keep this shared layout until Cloudflare exposes separate production
22- and preview build-variable views.
23-
24- This template handles that dashboard limitation in ` scripts/build-cloudflare.ts ` :
25-
26- 1 . It reads ` WORKERS_CI_BRANCH ` .
27- 2 . It selects ` CONVEX_DEPLOY_KEY ` when the branch is ` main ` .
28- 3 . It selects ` PREVIEW_CONVEX_DEPLOY_KEY ` for every other branch.
29- 4 . It passes only the selected value to the Convex deploy subprocess as
30- ` CONVEX_DEPLOY_KEY ` .
21+ Cloudflare supplies each environment's ` CONVEX_DEPLOY_KEY ` to the build. The build script does not
22+ select between two key names. Convex checks the key's deployment type before deploying.
3123
32- That keeps the production key compatible with projects that do not use the
33- preview-aware wrapper, while still requiring a separate preview key for
34- non-production branches.
24+ Keep ` pnpm run build ` , ` pnpm run deploy ` , and ` pnpm run deploy:preview ` as the Builds commands.
25+ The deploy scripts run ` wrangler deploy ` and ` wrangler preview ` . Wrangler gets the Worker name from
26+ Workers Builds, so the template does not need a fixed name. ` previews: {} ` in ` wrangler.jsonc `
27+ permits native preview deployment; it does not enable preview builds in the dashboard.
3528
36- When configuring through the Builds API, write the same two secrets to both
37- triggers. When configuring through the dashboard, enter both secrets in its
38- build-variable table. The script selects the correct key for each branch and
39- keeps preview builds from falling back to the production key.
29+ When migrating an existing app, open ** Settings > Builds > Set up Worker Previews > Set up** ,
30+ then select ** Switch to Worker Previews** . Enable preview builds and replace the copied production
31+ key in Previews Base with the project's Preview key. Remove ` PREVIEW_CONVEX_DEPLOY_KEY ` from build settings.
32+ Existing branch previews keep their saved build variables. Use a new branch name after correcting
33+ Previews Base. Retrying or deleting the Worker preview does not reset those variables. Check both
34+ production and a new branch preview before finishing.
4035
4136## Build Ordering
4237
@@ -61,15 +56,14 @@ concurrency primitive.
6156
6257## Local Checks
6358
64- Local dry-runs can validate the Worker package without build secrets:
59+ Local builds do not deploy Convex, even when a deploy key exists in the shell. A local dry run
60+ builds and validates the Worker package without publishing it:
6561
6662``` sh
67- CLOUDFLARE_WORKER_NAME=my-worker vp run deploy:dry-run
68- CLOUDFLARE_WORKER_NAME=my-worker vp run deploy:preview:dry-run
63+ pnpm run deploy:dry-run --name my-worker
6964```
7065
71- If you set either deploy key locally, also set ` WORKERS_CI_BRANCH ` so the
72- script can choose the intended deployment target.
66+ Wrangler does not support a native preview dry run. Use a real test branch to verify a preview.
7367
7468## References
7569
0 commit comments