Run Wrangler in CI/CD
Create a Cloudflare API token
To create a token:
- Log in to the .
- Select the user icon on the top right of your dashboard > My Profile.
- Select > Create Token.
- Select Use template next to Edit Cloudflare Workers. All templates are prefilled with a token name and permissions. You also need to modify the account and zone resources you want assigned to the token.
- After editing your token, select Continue to summary and review the permissions before selecting create token.
- Create an
.envfile in your project directory and set
CLOUDFLARE_API_TOKENas the key and your token as the value.
You can also inline the value directly with the
npx wrangler deploy command. For example:
CLOUDFLARE_API_TOKEN=XXX npx wrangler deploy.
You have three options for telling Wrangler which Cloudflare account to use:
- If there is only one account associated with the API token, then the account ID is inferred automatically;
- Add the
account_idto the project’s
wrangler.tomlfile (for example,
account_id = "12345679").
- Add the account ID to the