This unofficial Action uses Cloudflare's API to purge their cache of your site. A Python 3.9+ interpreter is required (installed by default on GitHub-hosted runners).
As of April 1st, 2025, all purge methods are now available for all customers.
You can mix and match the various inputs however you want
(other than the zone and auth key). If you don't provide
files
or tags
or hosts
or prefixes
, then all files will be purged.
The zone ID of your Cloudflare site. Example:
023e105f4ecef8ad9ca31a8372d0c353
The Cloudflare API key you've generated for your zone. Example:
c2547eb745079dac9320b638f5e225cf483cc5cfdda41
A space separated list of URLs to purge. Example:
files: https://nathanv.me/assets/images/profile.png https://nathanv.me/assets/images/favicons/apple-touch-icon.png
URL and header pairs are not supported in this Action.
The key urls
is also accepted for backwards compatibility.
A space separated list of tags to purge. Example:
tags: some-tag another-tag
A space separated list of hosts to purge. Example:
hosts: nathanv.me blog.nathanv.me
A space separated list of prefixes to purge. Example:
prefixes: nathanv.me/assets/ blog.nathanv.me/assets
The path to the Python interpreter to use, in case you are using a self-hosted runner.
Defaults to python
. Must be Python 3.9 or higher.
Example:
python: /usr/bin/python3.10
None
- name: Purge cache
uses: nathanvaughn/[email protected]
# preferred
with:
cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
- name: Purge cache
uses: nathanvaughn/[email protected]
# legacy
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_AUTH_KEY: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
- name: Purge cache
uses: nathanvaughn/[email protected]
with:
cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
files: |
https://nathanv.me/assets/images/profile.png
https://nathanv.me/assets/images/favicons/apple-touch-icon.png
tags: |
some-tag
another-tag
hosts: |
nathanv.me
blog.nathanv.me
prefixes: |
nathanv.me/assets/
blog.nathanv.me/assets
- Click "Create Token", and scroll down to the bottom for "Create Custom Token". Click "Get started".
- Fill out the form. Make sure to give the permission of "Zone" -> "Cache Purge" -> "Purge". Either select a specific zone, or all zones in the account.
-
Click "Continue to summary", then "Create Token".
-
Copy the value of the token.
- To find the zone ID for your site, go to your dashboard for the zone, and look on the right-hand panel.
- Follow GitHub's documentation to add these values to your repository's secrets. It is under the "Settings" tab, then "Secrets and variables" and "Actions".