Created
August 14, 2026 19:00
-
-
Save jmarhee/a49c02400d1d846f5d1ee1c8ac8aa0b7 to your computer and use it in GitHub Desktop.
Purge Cloudflare zone cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CLOUDFLARE_ZONE_ID= | |
| CLOUDFLARE_API_TOKEN= | |
| # API Token requires `Zone.Cache Purge` permissions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -include .env | |
| export | |
| .PHONY: purge | |
| purge: | |
| @test -n "$(CLOUDFLARE_ZONE_ID)" || (echo "CLOUDFLARE_ZONE_ID unset"; exit 1) | |
| @test -n "$(CLOUDFLARE_API_TOKEN)" || (echo "CLOUDFLARE_API_TOKEN unset"; exit 1) | |
| @resp=$$(curl -fsS -X POST \ | |
| "https://api.cloudflare.com/client/v4/zones/$(CLOUDFLARE_ZONE_ID)/purge_cache" \ | |
| -H "Authorization: Bearer $(CLOUDFLARE_API_TOKEN)" \ | |
| -H "Content-Type: application/json" \ | |
| --data '{"purge_everything":true}'); \ | |
| echo "$$resp"; \ | |
| echo "$$resp" | grep -q '"success":[[:space:]]*true' || (echo "Cloudflare purge failed"; exit 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment