Cloudflare
Deploys a release artifact to Cloudflare, either as a Cloudflare Pages site or as a Cloudflare Worker with static assets.
The target extracts a ZIP artifact and shells out to the wrangler CLI to perform the deployment. wrangler is bundled in the Craft Docker image.
Configuration
Section titled “Configuration”| Option | Description |
|---|---|
deployType | pages (default) or worker. |
projectName | Cloudflare Pages project name. Required when deployType is pages. |
productionBranch | The Pages project’s production branch name. Passed to wrangler pages deploy --branch so a release always targets the production environment. Default: main. This is the Cloudflare environment selector, not your git release branch. |
wranglerCliPath | Path to the wrangler binary. Default: wrangler (or the WRANGLER_BIN env var). |
workingDir | Subdirectory within the extracted artifact to deploy from. For worker deploys this is where the wrangler.toml lives. |
Environment Variables
Section titled “Environment Variables”| Name | Description |
|---|---|
CLOUDFLARE_API_TOKEN | Cloudflare API token with permission to deploy Pages/Workers. |
CLOUDFLARE_ACCOUNT_ID | Cloudflare account ID. |
Both are required. They are passed to wrangler via the environment, never on the command line.
Default Behavior
Section titled “Default Behavior”By default, this target:
- Looks for a single artifact matching
cloudflare.zip(or*-cloudflare.zip). Override withincludeNames. - Extracts its contents (flattening a single top-level directory if present).
- Deploys via
wrangler.
Example
Section titled “Example”Cloudflare Pages (static site):
targets: - name: cloudflare deployType: pages projectName: my-docs-site productionBranch: mainCloudflare Worker (with a wrangler.toml in the artifact):
targets: - name: cloudflare deployType: worker workingDir: workerWorkflow
Section titled “Workflow”- Create a
cloudflare.zipartifact in your CI workflow (e.g. the built static site, or your Worker pluswrangler.toml). - Configure the target in
.craft.yml. - Set
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDin your environment.