Skip to content

niwanetwork/actions-cloudflare-purge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare Cache Purge Action

Code style: black

This action uses Cloudflare's API to purge their cache of your site.

Inputs

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.

cf_zone or CLOUDFLARE_ZONE environment variable

The zone ID of your Cloudflare site. Example:

023e105f4ecef8ad9ca31a8372d0c353

cf_auth or CLOUDFLARE_AUTH_KEY environment variable

The Cloudflare API key you've generated for your zone. Example:

c2547eb745079dac9320b638f5e225cf483cc5cfdda41

files (optional)

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

The key urls is also accepted for backwards compatibility.

tags (optional)

A space separated list of tags to purge. Example:

tags: some-tag another-tag

hosts (optional)

A space separated list of hosts to purge. Example:

hosts: nathanv.me blog.nathanv.me

prefixes (optional)

A space separated list of prefixes to purge. Example:

prefixes: nathanv.me/assets/ blog.nathanv.me/assets

Outputs

None

Example Usages

- name: Purge cache
  uses: nathanvaughn/actions-cloudflare-purge@master
  # preferred
  with:
      cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
      cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
- name: Purge cache
  uses: nathanvaughn/actions-cloudflare-purge@master
  # legacy
  env:
      CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
      CLOUDFLARE_AUTH_KEY: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
- name: Purge cache
  uses: nathanvaughn/actions-cloudflare-purge@master
  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

Getting Cloudflare Info

  1. First, go to the API tokens page in your Cloudflare account.

  1. Click "Create Token", and fill out the form. Make sure to give the permission of zone cache purge.

  1. Click "Continue to summary", then "Confirm".

  2. Copy the value of the token.

  1. To find the zone ID for your site, go to your dashboard for the site, and look on the right-hand panel.

Follow GitHub's documentation to add these values to your repository's secrets.

About

A GitHub Action to purge Cloudflare's cache of your site

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.5%
  • Dockerfile 0.5%