Cloudflare Operations
Deploy static sites to Cloudflare Pages using the wrangler CLI.
Operations
| Operation | Description |
|---|---|
Cloudflare.EnsureAuthenticated | Verify Cloudflare credentials. Prompts interactively if environment variables are not set. See authentication for setup. |
Cloudflare.PagesDeploy | Deploy the ./dist directory to Cloudflare Pages. |
Cloudflare.PagesDeployDirectory | Deploy a specific output directory to Cloudflare Pages. |
Cloudflare.PagesListProjects | List all Cloudflare Pages projects. |
Cloudflare.PagesCreateProject | Create a new Cloudflare Pages project. |
Cloudflare.PagesListDeployments | List deployments for a Cloudflare Pages project. |
Authentication
Cloudflare operations require an API token and account ID. Set these as environment variables or enter them when prompted.
Environment Variables
| Variable | Description |
|---|---|
CLOUDFLARE_API_TOKEN | API token with Cloudflare Pages permissions |
CLOUDFLARE_ACCOUNT_ID | Your Cloudflare account ID (found in dashboard URL) |
CLOUDFLARE_PROJECT_NAME | Optional default project name for Pages operations |
Interactive Prompting
When running locally without environment variables set, Cloudflare.EnsureAuthenticated()
will prompt for credentials interactively. The API token input is hidden for security.
Credentials are only stored for the current build session and are cleared when the process exits.
Creating a Cloudflare API Token
- Go to Cloudflare Dashboard → Profile → API Tokens
- Click Create Token
- Select Edit Cloudflare Workers template (includes Pages permissions)
- Under Account Resources, select your account
- Under Zone Resources, select All zones or specific zones
- Click Continue to summary, then Create Token
- Copy the token and set it as
CLOUDFLARE_API_TOKEN
Finding Your Account ID
Your account ID is in the Cloudflare dashboard URL: https://dash.cloudflare.com/ACCOUNT_ID/...
Or find it on any zone's overview page in the right sidebar under API → Account ID.
Example
Deploy a static site to Cloudflare Pages.
build.ando
// Ensure we're authenticated with Cloudflare
Cloudflare.EnsureAuthenticated();
// Build the site
Npm.InDirectory("./website").Ci();
Npm.InDirectory("./website").Run("build");
// Deploy to Cloudflare Pages
Cloudflare.InDirectory("./website").PagesDeploy(o => o
.WithProjectName("my-website")
.WithBranch("main"));