Running Wrangler in CI/CD
To run Wrangler in a continuous integration/continuous deployment (CI/CD) environment, you must provide a Cloudflare API token and account ID.
Create a Cloudflare API token
To create a token:
- Log in to the Cloudflare dashboard.
- Select the user icon on the top right of your dashboard > My Profile.
- Select API Tokens > 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
wrangler publish command. For example:
CLOUDFLARE_API_TOKEN=XXX wrangler publish.
Refer to API Token for more information on set up.
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