Skip to content

cssnr/cloudflare-purge-cache-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Tag Major GitHub Tag Minor GitHub Release Version GHCR Size Workflow Release Workflow Test Workflow Lint GitHub Last Commit Codeberg Last Commit GitHub Top Language GitHub Org Stars Discord

Cloudflare Purge Cache Action

Purge Cloudflare cache for a zone or list of zones with optional filters including files, prefixes, tags, and hosts.

For more details see: action.yaml and src/main.py.

Inputs

Input Req. Default Input Description
token Yes - Cloudflare API Token
zones Yes - Zone Names to Purge *
files - - Files to Purge *
prefix - - Prefix Prepended to Files *
tags - - Tags to Purge (Enterprise only) *
hosts - - Hosts to Purge (Enterprise only) *
prefixes - - Prefixes to Purge (Enterprise only) *
fail - all Fail Mode: [all, any, none]
summary - true Add Summary to Job *
dry_run - false Run Without Purging

zones: CSV or Newline Delimited list of zone names to purge.

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.

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, hostname, prefix.

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
zones: cssnr.com,example.com
files:
prefix:
tags:
hosts:
prefixes:
fail: all
summary: true
dry_run: true

With minimal inputs, this will purge everything:

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

- 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

Outputs

Output Output Description
success Successful Zones, CSV
failed Failed Zones, CSV
- 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

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 are maintained.

Version Tag Rolling Bugs Feat. Name Target Example
GitHub Tag Major Major vN.x.x vN
GitHub Tag Minor Minor vN.N.x vN.N
GitHub Release Micro vN.N.N vN.N.N

You can view the release notes for each version on the 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:

If you are experiencing an issue/bug or getting unexpected results, you can:

Contributing

Currently, the best way to contribute to this project is to star this project on GitHub.

If you would like to submit a PR, please review the CONTRIBUTING.md.

Additionally, you can support other GitHub Actions I have published:

For a full list of current projects to support visit: https://cssnr.github.io/

About

Cloudflare Purge Cache Action

Topics

Resources

License

Stars

Watchers

Forks

Packages