-
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (54 loc) · 1.67 KB
/
purge-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: ♻️ Purge Cloudflare cache
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
purge:
name: ♻️ Purge Cloudflare cache
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: 📥 Install dependencies
uses: pnpm/action-setup@v2
with:
version: 8
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- name: 📦 Build current commit
run: |
pnpm run build
mv ./build ./current
- name: 📦 Build previous commit
run: |
git checkout HEAD^
pnpm install --frozen-lockfile --strict-peer-dependencies
pnpm run build
mv ./build ./previous
- name: 📝 Generate diff
id: diff
run: |
DIFF=$(diff -qr ./current ./previous)
if [ -z "$DIFF" ]; then
echo "has_diff=false" >> $GITHUB_OUTPUT
else
echo "has_diff=true" >> $GITHUB_OUTPUT
fi
- name: ♻️ Purge Cloudflare cache
uses: jakejarvis/cloudflare-purge-action@v0.3.0
if: steps.diff.outputs.has_diff == 'true'
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
PURGE_URLS: '["https://www.mcan.sh", "https://www.mcan.sh/resume", "https://www.mcan.sh/resume.pdf"]'