Cloudflare Production Cache Purge Update
Section titled “Cloudflare Production Cache Purge Update”This update adds automatic full Cloudflare cache purge after a successful production deployment.
.github/workflows/cloudflare-production-cache-purge.yml- Runs on successful production
deployment_statusevents. - Supports manual
workflow_dispatchruns. - Calls Cloudflare with
purge_everything. - Uses
CLOUDFLARE_API_TOKENandCLOUDFLARE_ZONE_IDGitHub Actions secrets.
- Runs on successful production
scripts/cloudflare_purge_cache.mjs- Validates required secrets.
- Supports dry-run mode.
- Calls Cloudflare’s zone purge endpoint without logging secrets.
.github/workflows/cloudflare-production-cache-purge-regression.yml- Runs regression checks on pull requests and pushes to
main.
- Runs regression checks on pull requests and pushes to
scripts/cloudflare_production_cache_purge_regression.mjs- Locks the expected production-only trigger, secrets usage, purge-everything behavior, and immutable guard coverage.
docs/CLOUDFLARE_PRODUCTION_CACHE_PURGE.md- Documents setup, required secrets, testing, and production verification.
Required GitHub secrets
Section titled “Required GitHub secrets”Add these in the NutsNews GitHub repo under Settings → Secrets and variables → Actions:
CLOUDFLARE_API_TOKENCLOUDFLARE_ZONE_IDThe Cloudflare token should be scoped only to the NutsNews zone and only needs cache purge permission.
Immutable test policy
Section titled “Immutable test policy”The new purge automation and regression files are added to the immutable test guard. Future changes require Rami’s explicit approval phrase in the PR title or body:
IMMUTABLE TEST CHANGE APPROVED BY RAMIThis PR modifies the immutable guard to add the new locked files, so the PR body should include that approval phrase for this one-time locking update.
Local verification
Section titled “Local verification”Run from the repo root:
node scripts/cloudflare_production_cache_purge_regression.mjsOptional dry run:
CLOUDFLARE_API_TOKEN=example-token \CLOUDFLARE_ZONE_ID=00000000000000000000000000000000 \CLOUDFLARE_PURGE_DRY_RUN=true \node scripts/cloudflare_purge_cache.mjs