Purge Cloudflare cache for a zone or list of zones with optional filters including files, prefixes, tags, and hosts.
Loaded with Options including job summary, fail mode, dry run, custom files prefix and Outputs.
- name: 'Purge Cache Action'
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: cssnr.com,example.comFor more details see: action.yaml and src/main.py.
| Input | Default | Short Description of the Input Value |
|---|---|---|
| token | Required | Cloudflare API Token |
| zones | Required | Zone Names to Purge |
| files | - | Files to Purge |
| prefix | - | Prefix Prepended to files |
| tags | - | Tags to Purge (Enterprise) |
| hosts | - | Hosts to Purge (Enterprise) |
| prefixes | - | Prefixes to Purge (Enterprise) |
| fail | all |
Fail Mode: [all, any, none] |
| dry_run | false |
Run Without Purging |
| summary | true |
Add Summary to Job |
You need a Cloudflare Token with the permission Zone.Cache Purge.
CSV or Newline Delimited list of zone names to purge.
View CSV and Newline Delimited Examples
CSV - Comma Seperated Value:
zones: cssnr.com,example.comNewline Delimited:
zones: |
cssnr.com
example.comCSV or Newline Delimited list of files to purge. This is limited to 30 files on the free plan and 500 for enterprise. For more information view docs for purge by file.
If provided, the prefix will be prepended to all the files. Useful for generating full links from file paths.
Enterprise Only. CSV or Newline Delimited list of tags, hosts or prefixes to purge.
For more information view docs for purge by tags, hostname, prefix.
When purging multiple domains, set when the action should fail.
Options are all, any or none. Default is all.
With this enabled it will only output the results and not purge any cache.
Write a Summary for the job. To disable this set to false.
👀 View Example Job Summary
dry_run to purge cache.
Purge Results
| 🚽 | Zone |
|---|---|
| ✅ | cssnr.com |
| ⛔ | example.com |
Inputs
zones: cssnr.com,example.com
files:
prefix:
tags:
hosts:
prefixes:
fail: all
summary: true
dry_run: true
View the Examples to see more...
| Output | Output Description |
|---|---|
| success | Successful Zones, CSV |
| failed | Failed Zones, CSV |
- name: 'Purge Cache Action'
id: purge
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: cssnr.com,example.com
- name: 'Echo Output'
run: |
echo "success: '${{ steps.purge.outputs.success }}'"
echo "failed: '${{ steps.purge.outputs.failed }}'"With minimal inputs, this will purge everything:
- name: 'Purge Cache Action'
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: cssnr.com,example.comTo limit what is purged, specify either files, tags, hosts, or prefixes.
With all inputs:
- name: 'Purge Cache Action'
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: cssnr.com
files: |
favicon.ico
static/logo.png
prefix: 'https://cssnr.com/'
tags: prod, dev
hosts: example.com, dev.example.com
prefixes: |
example.com
example.com/foo
fail: all
summary: true
dry_run: falseWorkflow Example.
name: 'Cloudflare Purge Cache'
on:
push:
jobs:
test:
name: 'Test'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: 'Purge Cache Action'
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: |
cssnr.com
example.comFor more examples, you can check out other projects using this action:
https://github.com/cssnr/cloudflare-purge-cache-action/network/dependents
The following rolling tags are maintained.
| Version Tag | Rolling | Bugs | Feat. | Name | Target | Example |
|---|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | Major | vN.x.x |
vN |
|
| ✅ | ✅ | ❌ | Minor | vN.N.x |
vN.N |
|
| ❌ | ❌ | ❌ | Micro | vN.N.N |
vN.N.N |
You can view the release notes for each version on the releases page.
The Major tag is recommended. It is the most up-to-date and always backwards compatible. Breaking changes would result in a Major version bump. At a minimum you should use a Minor tag.
For general help or to request a feature, see:
- Q&A Discussion: https://github.com/cssnr/cloudflare-purge-cache-action/discussions/categories/q-a
- Request a Feature: https://github.com/cssnr/cloudflare-purge-cache-action/discussions/categories/feature-requests
If you are experiencing an issue/bug or getting unexpected results, you can:
- Report an Issue: https://github.com/cssnr/cloudflare-purge-cache-action/issues
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
- Provide General Feedback: https://cssnr.github.io/feedback/
For more information, see the CSSNR SUPPORT.md.
Please consider making a donation to support the development of this project and additional open source projects.
If you would like to submit a PR, please review the CONTRIBUTING.md.
Additionally, you can support other GitHub Actions I have published:
- Stack Deploy Action
- Portainer Stack Deploy Action
- Docker Context Action
- VirusTotal Action
- Mirror Repository Action
- Update Version Tags Action
- Docker Tags Action
- Update JSON Value Action
- JSON Key Value Check Action
- Parse Issue Form Action
- Cloudflare Purge Cache Action
- Mozilla Addon Update Action
- Package Changelog Action
- NPM Outdated Check Action
- Label Creator Action
- Algolia Crawler Action
- Upload Release Action
- Check Build Action
- Web Request Action
- Get Commit Action
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- cssnr/draft-release-action - Keep a draft release ready to publish.
- cssnr/env-json-action - Convert env file to json or vice versa.
- cssnr/push-artifacts-action - Sync files to a remote host with rsync.
- smashedr/update-release-notes-action - Update release notes.
- smashedr/combine-release-notes-action - Combine release notes.
📝 Template Actions
These are basic action templates that I use for creating new actions.
- js-test-action - JavaScript
- py-test-action - Python
- ts-test-action - TypeScript
- docker-test-action - Docker Image
Note: The docker-test-action builds, runs and pushes images to GitHub Container Registry.
For a full list of current projects visit: https://cssnr.github.io/