Skip to content
Latchkey

wrangler deploy: Publish Cloudflare Workers in CI

wrangler deploy builds and uploads your Worker to Cloudflare, replacing the older wrangler publish.

wrangler deploy is the core publish command for Workers. In CI it reads credentials from environment variables and the target config from wrangler.toml.

What it does

wrangler deploy bundles the Worker entry point, applies the bindings declared in wrangler.toml (KV, D1, R2, secrets), and uploads it to the account and route configured. --env selects a named environment block from wrangler.toml for staging vs production.

Common usage

Terminal
# token + account id come from env vars in CI
export CLOUDFLARE_API_TOKEN=xxx CLOUDFLARE_ACCOUNT_ID=yyy
wrangler deploy
# deploy a named environment from wrangler.toml
wrangler deploy --env production

Options

FlagWhat it does
--env <name>Use a [env.<name>] block from wrangler.toml
--name <worker>Override the Worker name
--var KEY:valueInject a plaintext build var
--minifyMinify the bundle before upload
--dry-runBuild without uploading
CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_IDCI credentials via env vars

In CI

Set CLOUDFLARE_API_TOKEN (a scoped API token, not a global key) and CLOUDFLARE_ACCOUNT_ID as env vars; wrangler is non-interactive when both are present. Pin the wrangler version in your devDependencies so CI matches local behavior.

Common errors in CI

"Authentication error [code: 10000]" means the API token is missing, expired, or lacks the Workers Scripts edit permission. "More than one account available but unable to select one in non-interactive mode" means CLOUDFLARE_ACCOUNT_ID is unset. "A compatibility_date is required" means wrangler.toml is missing that field.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →