Appearance
Deploy to staging
For: putting a build in front of yourself on a real deployment, before it goes in front of players.
Staging is the worker named grafted-wars-true-staging. It answers on its workers.dev address and binds no custom domain. Its universe is reset freely and its store carries nothing you need to keep.
Preconditions
- [ ] The gate is green on the branch being deployed (
npm run check). - [ ]
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDare set, in the environment or the repository's gitignored.envfile. - [ ] An owner token has been minted on this machine, if you intend to claim owner (
node scripts/owner-claim.mjs mint).
Rehearse it first
The deploy has a dry run that needs no Cloudflare credentials at all. It prints the exact wrangler invocation and stops:
bash
GW_DEPLOY_DRY=1 npm run deploy:stagingRead the variables it reports. Every one it sets is printed, except the owner claim hash and the reset token, whose values are withheld.
Steps
Deploy.
bashnpm run deploy:staging- Expect: a build, then a wrangler upload, then a one-line summary naming the worker.
- If instead a
RED:-prefixed line appears: the exit code says which.2means a missing Cloudflare credential.1means the build failed, the wrangler upload failed, or the named starting stocks were not recognised.
On the very first deploy of this worker only, give it its admin secret.
bashnpx wrangler secret put ADMIN_EMAIL --name grafted-wars-true-staging- Expect: wrangler confirms the secret was set.
- This is separate from production's secret. Setting one does nothing for the other.
Check the worker answers.
bashcurl https://<the workers.dev address>/api/health- Expect: a JSON body reporting
ok, the worker name and its version. - If instead every request is refused: the
ADMIN_EMAILsecret has never been set on this worker. That is step 2, not a broken deploy.
- Expect: a JSON body reporting
Claim owner, if you want the admin surface.
bashnode scripts/owner-claim.mjs page <staging base url>- Expect: a claim-link page written to
~/rocket-showroom/grafted-wars-enter.html. Open it and follow the staging link once.
- Expect: a claim-link page written to
Optionally, mint throwaway accounts for a walkthrough.
bashnode tools/mint-accounts.mjs --base-url <staging base url>
What staging turns on that production does not
The deploy script sets four variables that differ from the production-safe defaults baked into the configuration file.
| Variable | Staging | Why |
|---|---|---|
GW_PUBLIC_SIGNUP | on | so accounts can be made without an invitation |
ADMIN_ROUTES | on | so the admin and export routes answer |
GW_DENSE_SEED | on | so the home system is packed at boot rather than filling over time |
GW_CLOCK_RATE | 25 | so a universe's worth of change happens in an evening |
Each can be overridden by setting the same name in your environment. Setting one to an empty string falls back to the configuration file's production-safe value for that variable alone, rather than dropping it.
Resetting the universe
Staging is wiped by giving it a reset token it has not seen before. The universe drops every user-state table on its next boot when the value differs from the one already stored:
bash
GW_STAGING_RESET=$(date +%s) npm run deploy:stagingA repeated value does nothing, because the comparison is against the stored one. Each reset needs a new value, which is why the example uses a timestamp.
Rollback
There is no rollback command. Undoing a bad staging deploy means checking out a known-good commit and deploying again.
Staging never touches domain bindings, so a failed or partial deploy leaves no DNS state behind. What remains is the worker at whatever version the last completed upload put there.
Sharp edges
The two worker names are reversed from what they read like. Staging is grafted-wars-true-staging; the worker called grafted-wars-staging is production. Check a deploy by the hostname it answers on rather than by the name in the dashboard.
A densely seeded universe running at 25x under sustained bot load can exceed the Durable Objects free-tier row-read quota. That is a plan limit rather than a defect in the deploy.
An owner claim hash supplied as an environment override must be a 64-character hex digest. A malformed one crashes the script before anything is built, with an uncaught exception rather than the script's own error line.