Skip to content

Clean up outdated preview deployments - #110

Merged
stefan-ka merged 1 commit into
masterfrom
chore/preview-cleanup
Oct 23, 2026
Merged

stefan-ka merged 1 commit into
masterfrom
chore/preview-cleanup

Conversation

@stefan-ka

Copy link
Copy Markdown
Member

Cloudflare Pages never deletes deployments on its own. Storage isn't a problem (static files, not billed), but the list of deployments and branch aliases would grow forever, and previews of deleted branches would stay reachable.

The new workflow preview-cleanup.yml deletes:

  • all preview deployments of branches that no longer exist on GitHub,
  • all but the latest preview deployment of each existing branch (the branch URL https://<branch>.contextmapper-preview.pages.dev always points to the latest one and keeps working).

It runs when a branch is deleted (e.g. after merging a PR), weekly (Monday 03:00 UTC), and manually. It uses the existing CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID secrets.

I tested the selection logic with mock deployment data; the Cloudflare API calls can only be tested after the merge (manual run).

Cloudflare Pages keeps all deployments. Delete the preview deployments of
deleted branches and all but the latest one of each existing branch when
a branch is deleted, weekly, and on demand.
@stefan-ka
stefan-ka merged commit 464d9c4 into master Oct 23, 2026
2 checks passed
@stefan-ka
stefan-ka deleted the chore/preview-cleanup branch October 23, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant