https://github.com/cssnr/cloudflare-purge-cache-action
Cloudflare Purge Cache Action
https://github.com/cssnr/cloudflare-purge-cache-action
actions
Last synced: about 1 month ago
JSON representation
Cloudflare Purge Cache Action
- Host: GitHub
- URL: https://github.com/cssnr/cloudflare-purge-cache-action
- Owner: cssnr
- License: gpl-3.0
- Created: 2023-09-02T23:26:34.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-14T23:58:37.000Z (over 1 year ago)
- Last Synced: 2025-02-15T00:28:05.248Z (over 1 year ago)
- Topics: actions
- Language: Python
- Homepage: https://cssnr.github.io
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/cssnr/cloudflare-purge-cache-action/tags)
[](https://github.com/cssnr/cloudflare-purge-cache-action/releases)
[](https://github.com/cssnr/cloudflare-purge-cache-action/releases/latest)
[](https://github.com/cssnr/cloudflare-purge-cache-action/blob/master/action.yaml)
[](https://github.com/cssnr/cloudflare-purge-cache-action/pkgs/container/cloudflare-purge-cache-action)
[](https://github.com/cssnr/cloudflare-purge-cache-action/pkgs/container/cloudflare-purge-cache-action)
[](https://github.com/cssnr/cloudflare-purge-cache-action/blob/master/action.yaml#L65)
[](https://github.com/cssnr/cloudflare-purge-cache-action/actions/workflows/release.yaml)
[](https://github.com/cssnr/cloudflare-purge-cache-action/actions/workflows/test.yaml)
[](https://github.com/cssnr/cloudflare-purge-cache-action/actions/workflows/lint.yaml)
[](https://github.com/cssnr/cloudflare-purge-cache-action/pulse)
[](https://codeberg.org/cssnr/cloudflare-purge-cache-action)
[](https://github.com/cssnr/cloudflare-purge-cache-action?tab=readme-ov-file#readme)
[](https://github.com/cssnr/cloudflare-purge-cache-action)
[](https://github.com/cssnr/cloudflare-purge-cache-action/graphs/contributors)
[](https://github.com/cssnr/cloudflare-purge-cache-action/discussions)
[](https://github.com/cssnr/cloudflare-purge-cache-action/forks)
[](https://github.com/cssnr/cloudflare-purge-cache-action/stargazers)
[](https://cssnr.github.io/)
[](https://discord.gg/wXy6m2X8wY)
[](https://ko-fi.com/cssnr)
# Cloudflare Purge Cache Action
- [Inputs](#Inputs)
- [Outputs](#Outputs)
- [Examples](#Examples)
- [Tags](#Tags)
- [Support](#Support)
- [Contributing](#Contributing)
Purge Cloudflare cache for a zone or list of zones with optional filters including files, prefixes, tags, and hosts.
Loaded with [Options](#inputs) including job summary, fail mode, dry run, custom files prefix and [Outputs](#outputs).
```yaml
- name: 'Purge Cache Action'
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: cssnr.com,example.com
```
For more details see: [action.yaml](action.yaml) and [src/main.py](src/main.py).
## Inputs
| Input | Default | Short Description of the Input Value |
| :-------- | :--------- | :------------------------------------------------------------ |
| **token** | _Required_ | Cloudflare API Token [⤵️](#token) |
| **zones** | _Required_ | Zone Names to Purge [⤵️](#zones) |
| files | - | Files to Purge [⤵️](#files) |
| prefix | - | Prefix Prepended to `files` [⤵️](#prefix) |
| tags | - | Tags to Purge (Enterprise) [⤵️](#tagshostsprefixes) |
| hosts | - | Hosts to Purge (Enterprise) [⤵️](#tagshostsprefixes) |
| prefixes | - | Prefixes to Purge (Enterprise) [⤵️](#tagshostsprefixes) |
| fail | `all` | Fail Mode: [`all`, `any`, `none`] [⤵️](#fail) |
| dry_run | `false` | Run Without Purging [⤵️](#dry_run) |
| summary | `true` | Add Summary to Job [⤵️](#summary) |
### token
You need a [Cloudflare Token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) with the permission `Zone.Cache Purge`.
### zones
CSV or Newline Delimited list of zone names to purge.
View CSV and Newline Delimited Examples
---
CSV - Comma Seperated Value:
```yaml
zones: cssnr.com,example.com
```
Newline Delimited:
```yaml
zones: |
cssnr.com
example.com
```
---
### files
CSV 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](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/).
### prefix
If provided, the `prefix` will be prepended to all the `files`. Useful for generating full links from file paths.
### tags/hosts/prefixes
_Enterprise Only._ CSV or Newline Delimited list of `tags`, `hosts` or `prefixes` to purge.
For more information view docs for purge by [tags](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/), [hostname](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-hostname/), [prefix](https://developers.cloudflare.com/cache/how-to/purge-cache/purge_by_prefix/).
### fail
When purging multiple domains, set when the action should fail.
Options are `all`, `any` or `none`. Default is `all`.
### dry_run
With this enabled it will only output the results and not purge any cache.
### summary
Write a Summary for the job. To disable this set to `false`.
👀 View Example Job Summary
---
⚠️ Only 1/2 Zones Purged!
⚠️ Dry Run! Remove or disable `dry_run` to purge cache.
Purge Results🚽Zone✅cssnr.com⛔example.com
Inputs
```yaml
zones: cssnr.com,example.com
files:
prefix:
tags:
hosts:
prefixes:
fail: all
summary: true
dry_run: true
```
---
View the [Examples](#examples) to see more...
## Outputs
| Output | Output Description |
| :------ | :---------------------- |
| success | Successful Zones, CSV |
| failed | Failed Zones, CSV |
```yaml
- 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 }}"
```
## Examples
With minimal inputs, this will **purge everything**:
```yaml
- name: 'Purge Cache Action'
uses: cssnr/cloudflare-purge-cache-action@v2
with:
token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
zones: cssnr.com,example.com
```
To limit what is purged, specify either `files`, `tags`, `hosts`, or `prefixes`.
With all inputs:
```yaml
- 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: false
```
Workflow Example.
```yaml
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.com
```
For more examples, you can check out other projects using this action:
https://github.com/cssnr/cloudflare-purge-cache-action/network/dependents
## Tags
The following rolling [tags](https://github.com/cssnr/cloudflare-purge-cache-action/tags) are maintained.
| Version Tag | Rolling | Bugs | Feat. | Name | Target | Example |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :--: | :---: | :-------: | :------: | :------- |
| [](https://github.com/cssnr/cloudflare-purge-cache-action/releases/latest) | ✅ | ✅ | ✅ | **Major** | `vN.x.x` | `vN` |
| [](https://github.com/cssnr/cloudflare-purge-cache-action/releases/latest) | ✅ | ✅ | ❌ | **Minor** | `vN.N.x` | `vN.N` |
| [](https://github.com/cssnr/cloudflare-purge-cache-action/releases/latest) | ❌ | ❌ | ❌ | **Micro** | `vN.N.N` | `vN.N.N` |
You can view the release notes for each version on the [releases](https://github.com/cssnr/cloudflare-purge-cache-action/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.
# Support
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/](https://cssnr.github.io/feedback/?app=Cloudflare%20Purge%20Cache%20Action)
For more information, see the CSSNR [SUPPORT.md](https://github.com/cssnr/.github/blob/master/.github/SUPPORT.md#support).
# Contributing
If you would like to submit a PR, please review the [CONTRIBUTING.md](#contributing-ov-file).
Please consider making a donation to support the development of this project
and [additional](https://cssnr.com/) open source projects.
[](https://ko-fi.com/cssnr)
[](https://actions-tools.cssnr.com/)
Additionally, you can support other [GitHub Actions](https://actions.cssnr.com/) I have published:
- [Stack Deploy Action](https://github.com/cssnr/stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy Action](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Docker Context Action](https://github.com/cssnr/docker-context-action?tab=readme-ov-file#readme)
- [Actions Up Action](https://github.com/cssnr/actions-up-action?tab=readme-ov-file#readme)
- [Zensical Action](https://github.com/cssnr/zensical-action?tab=readme-ov-file#readme)
- [VirusTotal Action](https://github.com/cssnr/virustotal-action?tab=readme-ov-file#readme)
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action?tab=readme-ov-file#readme)
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action?tab=readme-ov-file#readme)
- [Docker Tags Action](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
- [TOML Action](https://github.com/cssnr/toml-action?tab=readme-ov-file#readme)
- [Update JSON Value Action](https://github.com/cssnr/update-json-value-action?tab=readme-ov-file#readme)
- [JSON Key Value Check Action](https://github.com/cssnr/json-key-value-check-action?tab=readme-ov-file#readme)
- [Parse Issue Form Action](https://github.com/cssnr/parse-issue-form-action?tab=readme-ov-file#readme)
- [Cloudflare Purge Cache Action](https://github.com/cssnr/cloudflare-purge-cache-action?tab=readme-ov-file#readme)
- [Mozilla Addon Update Action](https://github.com/cssnr/mozilla-addon-update-action?tab=readme-ov-file#readme)
- [Package Changelog Action](https://github.com/cssnr/package-changelog-action?tab=readme-ov-file#readme)
- [NPM Outdated Check Action](https://github.com/cssnr/npm-outdated-action?tab=readme-ov-file#readme)
- [Label Creator Action](https://github.com/cssnr/label-creator-action?tab=readme-ov-file#readme)
- [Algolia Crawler Action](https://github.com/cssnr/algolia-crawler-action?tab=readme-ov-file#readme)
- [Upload Release Action](https://github.com/cssnr/upload-release-action?tab=readme-ov-file#readme)
- [Check Build Action](https://github.com/cssnr/check-build-action?tab=readme-ov-file#readme)
- [Web Request Action](https://github.com/cssnr/web-request-action?tab=readme-ov-file#readme)
- [Get Commit Action](https://github.com/cssnr/get-commit-action?tab=readme-ov-file#readme)
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- [cssnr/create-files-action](https://github.com/cssnr/create-files-action?tab=readme-ov-file#readme) - Create various files from templates.
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action?tab=readme-ov-file#readme) - Update release notes.
- [smashedr/combine-release-notes-action](https://github.com/smashedr/combine-release-notes-action?tab=readme-ov-file#readme) - Combine release notes.
---
📝 Template Actions
These are basic action templates that I use for creating new actions.
- [javascript-action](https://github.com/smashedr/javascript-action?tab=readme-ov-file#readme) - JavaScript
- [typescript-action](https://github.com/smashedr/typescript-action?tab=readme-ov-file#readme) - TypeScript
- [py-test-action](https://github.com/smashedr/py-test-action?tab=readme-ov-file#readme) - Dockerfile Python
- [test-action-uv](https://github.com/smashedr/test-action-uv?tab=readme-ov-file#readme) - Dockerfile Python UV
- [docker-test-action](https://github.com/smashedr/docker-test-action?tab=readme-ov-file#readme) - Docker Image Python
Note: The `docker-test-action` builds, runs and pushes images to [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).
---
For a full list of current projects visit: [https://cssnr.github.io/](https://cssnr.github.io/)