Skip to content

infrabill/actions-cloudflare-purge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 urls 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

urls (optional)

A space seperated list of URLs to purge. Example:

https://nathanv.me/assets/images/profile.png https://nathanv.me/assets/images/favicons/apple-touch-icon.png

tags (optional)

A space seperated list of tags to purge. Example:

some-tag another-tag

hosts (optional)

A space seperated list of hosts to purge. Example:

nathanv.me blog.nathanv.me

prefixes (optional)

A space seperated list of prefixes to purge. Example:

nathanv.me/assets/ blog.nathanv.me/assets

Outputs

None

Example Usages

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

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

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

  4. Copy the value of the token.

  5. 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.0%
  • Dockerfile 1.0%