Skip to content

Deploy your fork

The starter ships the way wrktr itself does: every landing deploys to dev, and a promote ships what’s on dev to production. Your fork’s environments start out not set up, because secrets aren’t copied with a fork. Three things make them yours, once.

In the Cloudflare dashboard, go to Manage Account > Account API Tokens > Create Token, with one permission: Account, Workers Scripts, Edit. Store it as the project’s secret from stdin, so it never lands in your shell history:

Terminal window
pbpaste | wrktr secret set CLOUDFLARE_API_TOKEN # macOS, from the clipboard
xclip -o | wrktr secret set CLOUDFLARE_API_TOKEN # Linux, from the clipboard
wrktr secret set CLOUDFLARE_API_TOKEN < token.txt # or from a file (delete it after)

The deploy never sees the token itself: its requests to the Cloudflare API get it from wrktr’s deploy gateway.

The two urls in wrktr.json are the starter’s. Change them to your Workers’ addresses:

"dev": { "url": "https://wrktr-starter-dev.<your-subdomain>.workers.dev", ... },
"production": { "url": "https://wrktr-starter.<your-subdomain>.workers.dev", ... }

wrktr checks each deploy is served there. Rename the Workers in wrangler.jsonc if you like.

Make this change on a branch, like any other (wrktr branch new my-urls), and land it.

wrangler.jsonc names no account, so a deploy goes to the one your token can reach. A token for several accounts needs "account_id": "<your account id>" in wrangler.jsonc.

The next landing deploys to dev by itself. Then:

Terminal window
wrktr env ls # what's live where, and what production is behind
wrktr env logs dev <run> --follow # stream a deploy
wrktr env promote production # ship what dev has to production

wrktr env promote production <commit> ships a specific commit (all 40 characters) that passed dev; an older one than what’s live is a rollback.

Every deploy serves /.well-known/wrktr.json (the project, environment, commit and run), added by wrktr with no change to the app, and wrktr env ls shows each environment as serving or not. See Environments.

An environment is a few lines of wrktr.json. A staging that deploys only when the app’s code changes, say:

"staging": {
"on": "land",
"changed": ["src/**", "public/**"],
"url": "https://wrktr-starter-staging.<your-subdomain>.workers.dev",
"secrets": ["CLOUDFLARE_API_TOKEN"],
"steps": [{ "name": "deploy", "run": "WRANGLER_SEND_METRICS=false npx wrangler deploy --env staging" }]
}

with a matching staging env in wrangler.jsonc ("staging": { "name": "wrktr-starter-staging" }). The wrktr.json reference has every field.