IT OPS

Cloudflare Pages preview purge for merged and deleted branches via GitHub

When a pull request is merged or its branch is deleted on GitHub, finds the matching Cloudflare Pages preview deployments for that branch, deletes them immediately.

CategoryIT Ops
Enginesim
Difficultyintermediate
Triggerevent
Steps5
Setup~15 min

How it runs

The automated pipeline, trigger to output.

  • TriggerGitHub PR merged or branch deletedGitHubGitHub
  • LogicExtract branch and confirm close/delete event
  • ActionList and filter Pages previews for the branchCloudflareCloudflare
  • ActionDelete matched preview deploymentsCloudflareCloudflare
  • OutputLog cleanup event to AxiomAxiom

What it does

Preview deployments are useful while a branch is open and pure waste once it merges. This event-driven template listens for GitHub pull-request-closed and branch-delete events, matches the branch name to its Cloudflare Pages preview deployments, and purges them right away — no waiting for a nightly retention window. Each cleanup is recorded in Axiom so you can see how much storage merged-branch hygiene is saving.

When to use it

Use this on repos with heavy preview-deploy traffic where stale previews pile up the moment work merges. It complements a time-based sweeper by reclaiming branch previews at the exact moment they become dead.

How it works

  1. 1A GitHub webhook fires on PR merge or branch deletion.
  2. 2A logic step extracts the branch name and confirms the event is a close or delete.
  3. 3Cloudflare lists preview deployments and filters to that branch.
  4. 4Cloudflare deletes the matched preview deployments and reports freed bytes.
  5. 5Axiom logs the branch, deployment count, and reclaimed storage.

Set it up

What you configure once, before turning it on.

  1. 1
    Connect GitHubRepos, issues, pull requests, actions.
  2. 2
    Connect CloudflareWorkers, Pages, R2, KV — the edge stack.
  3. 3
    Connect AxiomLog streams, queries, dashboards.
  4. 4
    Set each agent's modelWe leave models unset so you pick the tier — fast + cheap, or top-quality.
  5. 5
    Tune it to your dataEdit the prompts, filters, and field mappings so it matches how your team works.
  6. 6
    Test, then turn it onRun once against a sample, confirm the output, then enable the trigger.

Run this workflow in your colony.

14-day trial. No DevOps. No Sales call. Provisioned in under a minute.