• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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/cloudflare-purge-action@master
      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.

More Repositories

1

awesome-shodan-queries

๐Ÿ” A collection of interesting, funny, and depressing search queries to plug into shodan.io ๐Ÿ‘ฉโ€๐Ÿ’ป
5,688
star
2

s3-sync-action

๐Ÿ”„ GitHub Action to sync a directory with a remote S3 bucket ๐Ÿงบ
Shell
1,032
star
3

lighthouse-action

๐Ÿ’ก๐Ÿ  GitHub Action for running @GoogleChromeLabs Lighthouse webpage audits
Shell
343
star
4

subtake

Automatic finder for subdomains vulnerable to takeover. Written in Go, based on @haccer's subjack.
Go
145
star
5

datacenter-speed-tests

โšก Test speed and pings to all DigitalOcean, Linode, AWS, GCP, and Vultr regions
Shell
94
star
6

jarv.is

๐Ÿก My humble abode on the World Wide Web
MDX
91
star
7

bounty-domains

List of domains in scope for bug bounties (HackerOne, Bugcrowd, etc.)
70
star
8

wait-action

๐Ÿ’ค Very, very simple (and small) action to sleep for an amount of time โ€” 10s, 2m, etc.
Dockerfile
64
star
9

hugo-docker

โœ๏ธ Dockerized Hugo Extended with PostCSS, Babel, Pandoc, and more baked-in. Now with multi-architecture support!
Dockerfile
50
star
10

kitboga-bank

Mirror of Kitboga's fake bank account repository on BitBucket, please submit new themes there!
CSS
36
star
11

hugo-build-action

โœ๏ธ Hugo as a GitHub Action. Supports legacy versions back to v0.27 for compatibility.
Dockerfile
32
star
12

y2k

๐Ÿ’พ Windows Meยฎ, but fully isolated and disposable โ€”ย the way it was meant to be.
Ruby
32
star
13

docker-cloudflare-argo

An intermediary between Cloudflare's Argo tunneling service and your local containers/network.
Dockerfile
23
star
14

cloudflare-ufw-updater

๐Ÿ”ฅ ๐Ÿงฑ UFW rule updater to only allow HTTP and HTTPS traffic from Cloudflare IP address ranges
Shell
21
star
15

netlify-plugin-cache

โšก Generic plugin for caching any files and/or folders between Netlify builds
JavaScript
21
star
16

jakejarvis

hey ๐Ÿ‘‹
JavaScript
20
star
17

ios-trackers

Blocklist of tracking domains used by iOS and popular apps.
18
star
18

dotfiles

๐Ÿ’ป My .files
Shell
16
star
19

awesome-first-code

๐Ÿ‘ถ An awesome list for those who are brave enough to share their first programming projects ever. No shame allowed here!
15
star
20

simpip

๐ŸŒŽ A very "simple" web server that returns your IP address in plaintext...and literally nothing else.
JavaScript
15
star
21

hugo-mod-twemoji

Twemojis as a plug-and-play module for Hugo sites ๐Ÿ“ฆ
HTML
14
star
22

mastodon-installer

๐Ÿฆฃ Mastodon auto-installer for self-hosted instances
Shell
12
star
23

dark-mode

๐ŸŒ“ Super simple CSS theme switching with saved preferences and automatic OS setting detection
HTML
9
star
24

backblaze-b2-action

๐Ÿ”„ GitHub Action to sync a directory with a remote Backblaze B2 bucket ๐Ÿ”ฅ
Shell
9
star
25

mastodon-utils

๐Ÿฆฃ Small opinionated helper scripts, patches, and configs for Mastodon
Shell
9
star
26

firebase-deploy-action

๐Ÿ”ฅ GitHub Action to deploy a static site to Firebase Hosting
Dockerfile
8
star
27

npqueue

Active and queued player list for NoPixel GTA RP server
Go
7
star
28

jrvs.io

๐Ÿ”— Personal URL shortener
Shell
6
star
29

docker-lamp-php5

Legacy LAMP image with PHP 5.6 (EOL) & MySQL 5.7 on Ubuntu 16.04 Xenial. ๐Ÿšจ Use at your own risk!
Shell
5
star
30

candies

๐Ÿญ๐Ÿฌ Scrabble's flavo[u]r of @candybox2's delicious ฤame ๐Ÿฌ๐Ÿญ
JavaScript
4
star
31

careful-downloader

๐Ÿ•ต๏ธโ€โ™€๏ธ Downloads a file and its checksums, validates the hash, and optionally extracts it if safe.
JavaScript
4
star
32

spoons

๐Ÿฅ„ Online manager for offline spooning, for and by iD Tech Camps at Princeton University ๐Ÿฏ
HTML
4
star
33

docker-tor

๐Ÿง… A very simple Docker image that runs the Tor daemon
Dockerfile
4
star
34

tor-proxy-node

[๐Ÿšง VERY WIP] Quickly serve up a Tor proxy of your static clearnet site
JavaScript
3
star
35

stitches-normalize

๐Ÿงต @sindresorhus's modern-normalize.css as a plug-and-play JavaScript object compatible with Stitches.
TypeScript
3
star
36

dark-mode-example

๐ŸŒ“ Simple dark mode switching using local storage, OS preference detection, and minimal JavaScript
JavaScript
3
star
37

twemoji-emojis

๐Ÿ“ฆ A very simple NPM package that downloads Twemoji emojis (PNG and SVG)
JavaScript
3
star
38

imagemoji

๐Ÿ–ผ๏ธ Replaces emojis in strings or DOM nodes with corresponding images
TypeScript
3
star
39

hugo-uno

Personal Hugo boilerplate with Node, PostCSS, Autoprefixer, Netlify, etc.
HTML
2
star
40

website-stats

๐Ÿ“ˆ Daily snapshots of my website's hit counter data
JavaScript
2
star
41

comp40

COMP 40 at Tufts CS โ€“ย Machine Structure & Assembly Language Programming
C
2
star
42

phood

Photos of nearby phood. Group project for COMP 20 @tuftsdev, abandoned as of Spring 2015.
JavaScript
2
star
43

get-canonical-url

๐Ÿ”— Determines the current page's canonical URL and optionally normalizes it for consistency.
TypeScript
2
star
44

synonyms-for-awesome

๐Ÿ‘ฉโ€๐Ÿซ Making adjectives meritorious, exemplary, and supercalifragilisticexpialidocious again.โ„ข
HTML
2
star
45

homelab

๐Ÿงช Docker Compose service definitions for the various apps I have running on my home network.
2
star
46

simple-anchor

๐Ÿ”— A bare-bones fork of AnchorJS.
JavaScript
2
star
47

hass-config

My personal Home Assistant configuration ๐Ÿก
Python
1
star
48

dmnsrch.mobi

Quickly check domain name availability from your mobile device.
PHP
1
star
49

onlinenow

Facebook app that displays your online friends while you stay offline and invisible.
JavaScript
1
star
50

my-first-website

<marquee>My terrible, horrible, no good, very bad first website, circa 2001. ๐Ÿ‘ถ๐Ÿป</marquee>
HTML
1
star
51

JoeyTracker

iOS app for tracking shuttle buses at Tufts University. Abandoned as of 2016.
Objective-C
1
star
52

rsa-locksmith

Teeny tiny script to brute-force passphrases of RSA private keys ๐Ÿ”‘
Shell
1
star
53

jbb

A PHP bulletin board creatively titled Jake's Bulletin Board, circa 2003. (My first full coding project ever โ€“ย complete with bugs and security holes and horrendous style!)
PHP
1
star
54

jarv.is-hugo

Archived Hugo version of https://jarv.is/
JavaScript
1
star
55

vercel-esm-import-bug

TypeScript
1
star
56

node-module-template

Just a personal NPM/browser module boilerplate to my liking, probably not very useful to anybody else. ๐Ÿ˜Š
TypeScript
1
star