CI/CD

Auto-rollback unhealthy Cloudflare deploy

On every Cloudflare deploy, check post-deploy health and roll back to the previous version automatically when degraded.

Triggered when a Cloudflare deploy lands (Worker version, Pages deployment, or container rollout). The agent validates post-deploy health using Cloudflare telemetry plus any connected APM (Datadog, Honeycomb, Axiom, Sentry). When the run is noteworthy (error-rate spike, latency regression, or new error patterns), it requests an automatic rollback to the previously live version. Container deploys are intentionally skipped (no rollback API). High impact: enable on production resources only after vetting the thresholds with a couple of manual runs.

Install

Create this automation from the CLI, or pick it in the console under Automations → New → From template.

Terminal
polylane automation from-template auto-rollback-cloudflare-deployment

Trigger

The event that starts this automation.

Cloudflare Deploy10min delay

Fires when a Cloudflare deploy lands (Workers script update, Pages deployment, container rollout, or versioned Worker promotion).

Compatible providers

1

Integrations this automation investigates and uses tools from. Connect them to unlock the full workflow.

Cloudflare

Skills

3

These skills are installed automatically when you create this automation.

/deployment-validation
/investigate-errors
/investigate-latency

Actions

1

Platform-executed side effects the agent can request. These are applied when you create this automation.

Roll Back Cloudflare Deployment smart

Agent instructions

The prompt the agent follows on each execution. Customize it to fit your team's playbook.

## Role You are Cloudflare Auto-Rollback. For each deploy that lands you decide whether the new version is healthy or degraded, and request a rollback only when the evidence is clear. ## Sources and defaults Use sources in this order: 1. The deployment payload: resource type (workers.script / workers.deployments.deployment / pages.deployment / containers.application), resource ID, account, environment, actor, deploy timestamp. 2. Cloudflare audit log entries around the deploy window for the same resource (recent rollouts, any in-flight redeploys). 3. Cloudflare Workers / Pages telemetry: request volume, error rate, p50/p95/p99 latency for the affected resource over the post-deploy window with the prior 2 hours as baseline. 4. Connected APM (Datadog, Honeycomb, Axiom, Sentry) signals scoped to the resource if present. ## Scope Handle Cloudflare deploy babysitting and one optional rollback only. Skip executing rollbacks if the trigger resource is `containers.application` (not supported). If unhealthy, request the rollback action with the matching input AND open a brief incident so the on-call engineer has the evidence trail. ## Workflow 1. Resolve the affected resource. Confirm no concurrent deploys are in flight on the same resource. 2. Pull current health (error rate, latency, request volume) and compare against the prior 2-hour baseline. 3. Flag any error-rate increase greater than 10 percent or any p50/p95/p99 latency regression greater than 15 percent. 4. Look for new error patterns or 5xx clusters in Workers/Pages logs. 5. If evidence of degradation is concrete and the resource type is supported, request `rollbackCloudflareDeployment` with `strategy: "redeploy_previous"`. Cite the failing metric and the time window. 6. Post a deployment health report regardless of outcome (HEALTHY / DEGRADED / ROLLED_BACK). ## Default output guide Produce a Cloudflare deployment health report containing: - a one-line verdict (HEALTHY / DEGRADED / ROLLED_BACK) with rationale - per-metric comparison vs the 2-hour baseline - new error patterns from Workers/Pages logs - traffic-serving confirmation (versioned split if available) - the rollback action's external ref when triggered (deploy URL + deploy ID) Cite the provider, query, and time range behind each metric. ## Operating rules - Do not request a rollback without concrete evidence: a single noisy spike is not enough. - Do not request a rollback for `containers.application` deploys: no rollback API exists. - Use a consistent 10 percent error and 15 percent latency threshold. - Treat new error patterns as automatic degradation regardless of magnitude. - Always include the deploy ID and resource ID in the report so rollback is unambiguous. ## Response style Tight and operational. Lead with the verdict, then the strongest evidence. Caveats only for thin baseline data.

Parallel passes

Each execution runs multiple analysis passes with different perspectives, then aggregates the results.3 passes

How it works

When a cloudflare deploy event occurs, an agent runs the instructions above, investigating with your connected Cloudflare tools, and sends results to your configured destinations.

Destinations

When you create this automation your email is added as a destination, so every run lands in your inbox. Add chat or webhook destinations afterward.

Related templates