Skip to content

Commit befa830

Browse files
heiskrCopilot
andauthored
Add daily full-language soft-purge sweep to Fastly (#62178)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3379a99 commit befa830

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

.github/workflows/purge-fastly.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ name: Purge Fastly
99

1010
on:
1111
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 * * *'
1216
workflow_dispatch:
1317
inputs:
1418
languages:
@@ -58,6 +62,17 @@ jobs:
5862
- name: Check out repo
5963
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
6064

65+
- name: Generate GitHub App token
66+
# Lets a scheduled-run failure open a tracking issue in docs-engineering
67+
# (the default GITHUB_TOKEN can't write cross-repo).
68+
id: app-token
69+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
70+
with:
71+
app-id: ${{ secrets.DOCS_BOT_APP_ID }}
72+
private-key: ${{ secrets.DOCS_BOT_APP_PRIVATE_KEY }}
73+
owner: github
74+
repositories: docs-engineering
75+
6176
- uses: ./.github/actions/node-npm-setup
6277

6378
- name: Validate confirmation input
@@ -76,8 +91,9 @@ jobs:
7691
7792
- name: Purge Fastly
7893
# Auto post-deploy runs wait for the build, purge English only (temporary),
79-
# and stay soft. A manual run uses the inputs: blank languages = all, the
80-
# `hard` toggle, or a confirmed full-cache purge.
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.
8197
#
8298
# Raw inputs are passed through the environment and quoted, never spliced
8399
# into the command string, so a value like `en' --everything` can't break
@@ -89,10 +105,8 @@ jobs:
89105
EVERYTHING_INPUT: ${{ inputs.everything }}
90106
run: |
91107
args=()
92-
if [ "$EVENT_NAME" != "workflow_dispatch" ]; then
93-
args+=(--wait-for-build)
94-
fi
95108
if [ "$EVENT_NAME" = "deployment_status" ]; then
109+
args+=(--wait-for-build)
96110
args+=(--languages en)
97111
elif [ -n "$LANGUAGES_INPUT" ]; then
98112
args+=(--languages "$LANGUAGES_INPUT")
@@ -123,3 +137,8 @@ jobs:
123137
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
124138
with:
125139
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
140+
141+
- uses: ./.github/actions/create-workflow-failure-issue
142+
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
143+
with:
144+
token: ${{ steps.app-token.outputs.token }}

src/workflows/tests/actions-workflows.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ const alertWorkflows = workflows.filter(({ data }) =>
109109
)
110110
// to generate list, console.log(new Set(workflows.map(({ data }) => Object.keys(data.on)).flat()))
111111

112-
const dailyWorkflows = scheduledWorkflows.filter(({ data }) =>
113-
data.on.schedule!.find(({ cron }: { cron: string }) => /^20 \d{1,2} /.test(cron)),
114-
)
112+
const dailyWorkflows = scheduledWorkflows
113+
// purge-fastly's daily soft purge runs every day off-peak (02:20 UTC)
114+
.filter(({ filename }) => filename !== 'purge-fastly.yml')
115+
.filter(({ data }) =>
116+
data.on.schedule!.find(({ cron }: { cron: string }) => /^20 \d{1,2} /.test(cron)),
117+
)
115118

116119
// Weekly workflows have a single day-of-week digit (e.g. "20 16 * * 1")
117120
const weeklyWorkflows = dailyWorkflows.filter(({ data }) =>

0 commit comments

Comments
 (0)