All Projects โ†’ jakejarvis โ†’ Cloudflare Purge Action

jakejarvis / Cloudflare Purge Action

Licence: mit
๐Ÿ—‘๏ธ GitHub Action to purge a website's cache via the Cloudflare API

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Cloudflare Purge Action

Alpine Make Vm Image
Make customized Alpine Linux disk image for virtual machines
Stars: โœญ 145 (+119.7%)
Mutual labels:  deployment, ci
Rocket
Automated software delivery as fast and easy as possible ๐Ÿš€
Stars: โœญ 217 (+228.79%)
Mutual labels:  deployment, ci
Build
Netlify Build runs the build command, Build Plugins and bundles Netlify Functions.
Stars: โœญ 135 (+104.55%)
Mutual labels:  deployment, ci
Nitro Demo
nuxt nitro preview
Stars: โœญ 100 (+51.52%)
Mutual labels:  cloudflare, deployment
dockerized-drupal-starter
End-to-end (CI + CD) dockerized Drupal 8 starting point.
Stars: โœญ 27 (-59.09%)
Mutual labels:  deployment, ci
S3 Sync Action
๐Ÿ”„ GitHub Action to sync a directory with a remote S3 bucket ๐Ÿงบ
Stars: โœญ 497 (+653.03%)
Mutual labels:  deployment, ci
Mbt
The most flexible build tool for monorepo
Stars: โœญ 184 (+178.79%)
Mutual labels:  deployment, ci
kahoy
Simple Kubernetes raw manifests deployment tool
Stars: โœญ 33 (-50%)
Mutual labels:  deployment, ci
build-plugin-template
Template repository to create new Netlify Build plugins.
Stars: โœญ 26 (-60.61%)
Mutual labels:  deployment, ci
jekyll-deploy-action
๐Ÿช‚ A Github Action to deploy the Jekyll site conveniently for GitHub Pages.
Stars: โœญ 162 (+145.45%)
Mutual labels:  deployment, ci
Plek
Make continuous deployment delightful. Deploy and preview your apps for each pull request with Plek. ๐Ÿ‡ณ๐Ÿ‡ฑ
Stars: โœญ 15 (-77.27%)
Mutual labels:  deployment, ci
Simpleci
Simple docker-based continuous integration system
Stars: โœญ 61 (-7.58%)
Mutual labels:  ci
Piholecloudflared
Raspberry Pi setup with Pi-Hole, CloudflareD, DHCP as the ultimate Ad-blocker
Stars: โœญ 57 (-13.64%)
Mutual labels:  cloudflare
Laravel Caprover Template
Template to deploy a Laravel app in docker for CapRover
Stars: โœญ 56 (-15.15%)
Mutual labels:  deployment
Rsync
In the process of being transitioned to a node.js action.
Stars: โœญ 53 (-19.7%)
Mutual labels:  deployment
Kube Score
Kubernetes object analysis with recommendations for improved reliability and security
Stars: โœญ 1,128 (+1609.09%)
Mutual labels:  ci
K8s Config Projector
Create Kubernetes ConfigMaps from configuration files
Stars: โœญ 61 (-7.58%)
Mutual labels:  ci
Synologyddnscloudflaremultidomain
Synology DDNS Cloudflare service provider with multidomains and subdomains
Stars: โœญ 51 (-22.73%)
Mutual labels:  cloudflare
Npm Cache Resource
Concourse resource for caching dependencies
Stars: โœญ 51 (-22.73%)
Mutual labels:  ci
Graceful Shutdown Spring Boot
Graceful Shutdown with Spring Boot (Demo)
Stars: โœญ 51 (-22.73%)
Mutual labels:  deployment

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.

Usage

All sensitive variables should be set as encrypted secrets in the action's configuration.

Configuration Variables

Key Value Suggested Type Required
CLOUDFLARE_ZONE Required for both methods below. 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
PURGE_URLS Optional. An array of fully qualified URLs to purge. For example: ["https://jarv.is/style.css", "https://jarv.is/favicon.ico"]. If unset, the action will purge everything (which is suggested โ€” more info below). env No

Authentication Variables

Both authentication methods below require you to grab information from the API Tokens page in the dashboard. Details on the inner workings of each method can be found in Cloudflare's API docs.

Option 1: Restricted API Token

API Tokens are a new feature as of August 2019. They allow you to restrict the scope of this action to only purging the cache of zones you specify. In other words, this is much safer than allowing this action complete control of your entire Cloudflare account. (I'm not evil though, I promise. ๐Ÿ˜Š)

Key Value Type
CLOUDFLARE_TOKEN The restricted API Token with permissions to purge the cache of one or more zones. secret

Creating a token can be tricky, so here's what you should enter on this page to create a token for purging the cache of a single domain on your account:

Creating an API Token for purging

Option 2: Global API Key

This is the "traditional" method of authenticating โ€” simply grab your "Global API Key" from the dashboard. Using this method also requires a second environment variable with the email address linked to your account.

Key Value Type
CLOUDFLARE_EMAIL The email address you registered your Cloudflare account with. For example, [email protected]. secret
CLOUDFLARE_KEY Your Cloudflare API key, which can be generated using these instructions. secret

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/[email protected]
      env:
        # Zone is required by both authentication methods
        CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}

        CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
        # ...or:
        CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
        CLOUDFLARE_KEY: ${{ secrets.CLOUDFLARE_KEY }}

Purging specific files

To purge only specific files, you can pass an array of fully qualified URLs via a fourth environment variable named PURGE_URLS. Unfortunately, Cloudflare doesn't support wildcards (unless you're on the insanely expensive Enterprise plan) so in order to purge a folder, you'd need to list every file in that folder. It's probably safer to leave this out and purge everything, but in case you want really to, the syntax is as follows:

PURGE_URLS: '["https://jarv.is/style.css", "https://jarv.is/favicon.ico"]'

License

This project is distributed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].