You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/purge-fastly.yml
+69-50Lines changed: 69 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,50 @@
1
1
name: Purge Fastly
2
2
3
-
# **What it does**: Sends a soft-purge to Fastly.
4
-
# **Why we have it**: So that, right after a production deploy, we start afresh
5
-
# **Who does it impact**: Writers and engineers.
3
+
# **What it does**: Purges Fastly after a deploy and on demand. Soft purge by
4
+
# default; can hard purge specific languages, or hard purge the ENTIRE cache.
5
+
# **Why we have it**: So that, right after a production deploy, we start afresh,
6
+
# and so docs engineering can clear a bad cache state without the Fastly UI.
7
+
# **Who does it impact**: Writers and engineers. A full purge impacts all readers,
8
+
# origin sees a traffic spike while the cache refills, so it's gated below.
6
9
7
10
on:
8
11
deployment_status:
9
12
workflow_dispatch:
10
13
inputs:
11
14
languages:
12
-
description: "Comma separated languages. E.g. 'en,es,ja,pt,zh,ru,fr,ko,de' (defaults to en)"
15
+
description: "Comma separated languages, e.g. 'en,es,ja,pt,zh,ru,fr,ko,de'. Blank = all languages."
13
16
required: false
14
-
default: 'en'# Temporary, only purge English on deploy. Set to empty string for all
17
+
default: 'en'
18
+
hard:
19
+
description: 'Evict immediately instead of the default soft purge. Use when a soft purge fails to clear stale content.'
20
+
type: boolean
21
+
required: false
22
+
default: false
23
+
everything:
24
+
description: 'DANGER: hard-purge the ENTIRE Fastly cache... every key, all readers. Ignores the language/hard inputs. To confirm, type exactly: "purge everything". Otherwise leave blank.'
25
+
required: false
26
+
default: ''
15
27
16
28
permissions:
17
29
contents: read
18
30
31
+
# Serialize full-cache purges so two can't overlap and leave the cache in an
32
+
# unknown state. Every other run (per-deploy, per-language) gets a unique group
echo "Production matches the build commit ($consecutive/$required_matches)"
67
-
else
68
-
if [[ $consecutive -gt 0 ]]
69
-
then
70
-
echo "Production stopped matching the build commit; resetting consecutive count"
71
-
else
72
-
echo "Production is not up to date with the build commit"
73
-
fi
74
-
consecutive=0
75
-
fi
76
-
if [[ $consecutive -lt $required_matches ]]
77
-
then
78
-
sleep $interval_seconds
79
-
fi
80
-
done
81
-
echo "Production is up to date with the build commit ($required_matches consecutive matches)"
71
+
if [ -n "$EVERYTHING_INPUT" ] && [ "$EVERYTHING_INPUT" != "purge everything" ]; then
72
+
echo "::error::To purge the entire cache, the 'everything' input must be exactly 'purge everything'. Got: '$EVERYTHING_INPUT'. Leave it blank for a normal purge."
73
+
exit 1
74
+
fi
82
75
83
-
- name: Purge Fastly edge cache per language
76
+
- name: Purge Fastly
77
+
# Auto post-deploy runs wait for the build, purge English only (temporary),
78
+
# and stay soft. A manual run uses the inputs: blank languages = all, the
79
+
# `hard` toggle, or a confirmed full-cache purge.
80
+
#
81
+
# Raw inputs are passed through the environment and quoted, never spliced
82
+
# into the command string, so a value like `en' --everything` can't break
83
+
# out of its argument and inject another flag.
84
84
env:
85
-
LANGUAGES: ${{ inputs.languages || 'en' }} # Temporary, only purge English on deploy. Set to empty string for all
86
-
run: npm run purge-fastly-edge-cache-per-language
85
+
EVENT_NAME: ${{ github.event_name }}
86
+
LANGUAGES_INPUT: ${{ inputs.languages }}
87
+
HARD_INPUT: ${{ inputs.hard }}
88
+
EVERYTHING_INPUT: ${{ inputs.everything }}
89
+
run: |
90
+
args=()
91
+
if [ "$EVENT_NAME" != "workflow_dispatch" ]; then
92
+
args+=(--wait-for-build)
93
+
fi
94
+
if [ "$EVENT_NAME" = "deployment_status" ]; then
95
+
args+=(--languages en)
96
+
elif [ -n "$LANGUAGES_INPUT" ]; then
97
+
args+=(--languages "$LANGUAGES_INPUT")
98
+
fi
99
+
if [ "$HARD_INPUT" = "true" ]; then
100
+
args+=(--hard)
101
+
fi
102
+
if [ "$EVERYTHING_INPUT" = "purge everything" ]; then
0 commit comments