11name : Purge Fastly
22
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.
3+ # **What it does**:
4+ # On production deploy, hard-purge the changed English content pages by key.
5+ # On demand, soft or hard purge language keys, a single key, or entire cache.
6+ # **Why we have it**: So a just-deployed change is visible right away, and so
7+ # docs engineering can clear a bad cache state without the Fastly UI.
8+ # **Who does it impact**: Writers and engineers. A full purge impacts all readers
9+ # and spikes origin traffic while the cache refills, so it's gated below.
910
1011on :
1112 deployment_status :
12- schedule :
13- # Daily soft purge of all languages to catch reusables and AUTOTITLE links.
14- # Intentionally off-peak, around 6-7pm PT.
15- - cron : ' 20 2 * * *'
1613 workflow_dispatch :
1714 inputs :
1815 languages :
@@ -89,26 +86,22 @@ jobs:
8986 exit 1
9087 fi
9188
92- - name : Purge Fastly
93- # Auto post-deploy runs wait for the build, purge English only (temporary),
94- # and stay soft. The daily scheduled run waits for nothing, purges all
95- # languages (blank = all), and stays soft. A manual run uses the inputs:
96- # blank languages = all, the `hard` toggle, or a confirmed full-cache purge.
97- #
89+ - name : Wait for production to serve this build
90+ if : ${{ github.event_name == 'deployment_status' }}
91+ run : npm run wait-for-build
92+
93+ - name : Purge Fastly (manual)
9894 # Raw inputs are passed through the environment and quoted, never spliced
9995 # into the command string, so a value like `en' --everything` can't break
10096 # out of its argument and inject another flag.
97+ if : ${{ github.event_name == 'workflow_dispatch' }}
10198 env :
102- EVENT_NAME : ${{ github.event_name }}
10399 LANGUAGES_INPUT : ${{ inputs.languages }}
104100 HARD_INPUT : ${{ inputs.hard }}
105101 EVERYTHING_INPUT : ${{ inputs.everything }}
106102 run : |
107103 args=()
108- if [ "$EVENT_NAME" = "deployment_status" ]; then
109- args+=(--wait-for-build)
110- args+=(--languages en)
111- elif [ -n "$LANGUAGES_INPUT" ]; then
104+ if [ -n "$LANGUAGES_INPUT" ]; then
112105 args+=(--languages "$LANGUAGES_INPUT")
113106 fi
114107 if [ "$HARD_INPUT" = "true" ]; then
@@ -119,14 +112,9 @@ jobs:
119112 fi
120113 npm run purge-fastly -- "${args[@]}"
121114
122- - name : Hard-purge changed English content URLs
123- # Prod deploys only. The soft purge above just marks `language:en` stale,
124- # so stale-while-revalidate can keep serving the pre-deploy copy of a
125- # just-changed page for a while. This evicts the specific English URLs
126- # whose content/ files changed in this deploy, so the next request fetches
127- # fresh. By the time the deploy succeeds the old pods are already gone, so
128- # the refill is deterministically the new content. data/ changes stay
129- # covered by the soft purge above (too many URLs to enumerate cheaply).
115+ - name : Hard-purge changed English content pages
116+ # On prod deploys, evict the surrogate keys of the English content pages
117+ # whose content/ files changed in this deploy.
130118 if : ${{ github.event_name == 'deployment_status' }}
131119 env :
132120 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments