Git Product home page Git Product logo

cloudflare-purge-action's Introduction

GitHub Action to Purge Cloudflare Cache ๐Ÿ—‘๏ธ

โš ๏ธ Note: To use this action, you must have access to the GitHub Actions feature. GitHub Actions are currently only available in public beta. You can apply for the GitHub Actions beta here.

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 of your website.

As of now, this action will purge your entire zone โ€” in the near future, you'll be able to only purge specific files or tags.

Usage

workflow.yml Example

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 steps here to build your site, deploy it to a service, etc.

    - name: Purge cache
      uses: jakejarvis/cloudflare-purge-action@master
      env:
        CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
        CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
        CLOUDFLARE_KEY: ${{ secrets.CLOUDFLARE_KEY }}

If successful, you'll see the following message returned in your action's logs:

{"result":{"id":"***"},"success":true,"errors":[],"messages":[]}

Required Secret Variables

All variables should be added as "secrets" in the action's configuration.

Key Value Type Required
CLOUDFLARE_ZONE 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
CLOUDFLARE_EMAIL The email address you registered your Cloudflare account with. For example, [email protected]. secret Yes
CLOUDFLARE_KEY Your Cloudflare API key, which can be generated using these instructions. For example, abc123abc123abc123abc123abc123abc123abc123abc. secret Yes

To-Do

In the next few days...

  • Purge individual files by URL (docs)
  • Purge individual files by cache tag/host (docs) [Enterprise only]
  • Return a success/failed status message for the full CI experience

License

This project is distributed under the MIT license.

cloudflare-purge-action's People

Contributors

jakejarvis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.