Skip to content

rafaucau/purge-cloudflare-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

Cloudflare Purge Cache Action

This action uses Cloudflare's API to purge their cache of your website. It can be helpful after deploying a new version.

What makes this action different from similar ones is that it allows you to clean URL caches based on the XML sitemap. This way, if you want to purge specific files, you don't have to remember to update the workflow every time.

Configuration

Creating API tokens: https://developers.cloudflare.com/api/tokens/create/

All sensitive information like zones and tokens should be stored with encrypted secrets.

Usage

your-workflow.yml

#...      
  - name: Purge cache
    uses: rafaucau/[email protected]
    with:
      # Zone is required by both authentication methods
      zone: ${{ secrets.CLOUDFLARE_ZONE }}
      
      # Use API Token
      api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
      # OR use global API Key and Email
      api_key: ${{ secrets.CLOUDFLARE_API_KEY }}
      email: ${{ secrets.CLOUDFLARE_EMAIL }}

      # If the following options are not used, everything will be purged
      # [Optional] A space seperated list of URLs to purge
      files: https://example.com/1 https://example.com/2
      # [Optional] XML sitemap URL
      # Do not use this option if you want to purge everything!
      # If your sitemap is large, you'd better not use this option and purge everything
      sitemap: https://example.com/sitemap.xml
#... 

About

GitHub Action to purge a website's cache via the Cloudflare API

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project