Based on this Action from jakejarvis which seems unmaintained, and merged this PR from chabad360 to work with the new YAML syntax.
This simple action calls the Cloudflare API to purge the cache of your website, which can be a helpful last step after deploying a new version.
All sensitive variables should be set as encrypted secrets in the action's configuration.
Place in a .yml
file such as this one in your .github/workflows
folder. Refer to the documentation on workflow YAML syntax here.
name: Deploy my website
on: push
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Put other steps here if you'd like, i.e. to build your site, deploy it to a service, etc.
- name: Purge cache
uses: Jonakemon/cloudflare-purge-cache-action@v1.1.0
with:
cloudflareZone: ${{ secrets.CLOUDFLARE_ZONE }}
cloudflareApiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
Key | Value | Suggested Type | Required |
---|---|---|---|
cloudflareZone |
The Zone ID of your domain, which can be found in the right sidebar of your domain's overview page on the Cloudflare dashboard. For example, xyz321xyz321xyz321xyz321xyz321xy . |
secret |
Yes |
cloudflareApiKey |
Your Cloudflare API key, which can be generated using these instructions. For example, abc123abc123abc123abc123abc123abc123abc123abc . |
secret |
Yes |
API Tokens are a feature that allows you to restrict the scope of this action to only purging the cache of zones you specify. In other words, this is much safer than allowing this action complete control of your entire Cloudflare account.
Creating a token is easy; here's an example of what you should enter on this page to create a token for purging the cache of a single domain on your account:
This project is distributed under the MIT license. It is based on a similar repository from jakejarvis.