Skip to content

Commit ba3c870

Browse files
authored
Fix race condition in search index workflow triggering (#59276)
1 parent 46e3f3b commit ba3c870

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/index-general-search.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ on:
2626
permissions:
2727
contents: read
2828

29-
# This allows a subsequently queued workflow run to cancel previous runs
29+
# This allows a subsequently queued workflow run to cancel previous runs.
30+
# Include the triggering workflow's conclusion in the group so that runs triggered
31+
# by skipped Purge Fastly workflows don't cancel runs triggered by successful ones.
3032
concurrency:
31-
group: '${{ github.workflow }} @ ${{ github.head_ref }} ${{ github.event_name }}'
33+
group: '${{ github.workflow }} @ ${{ github.head_ref }} ${{ github.event_name }} ${{ github.event.workflow_run.conclusion }}'
3234
cancel-in-progress: true
3335

3436
env:
@@ -40,7 +42,9 @@ env:
4042

4143
jobs:
4244
figureOutMatrix:
43-
if: ${{ github.repository == 'github/docs-internal' }}
45+
# Skip immediately if triggered by a non-successful Purge Fastly run.
46+
# This prevents skipped runs from canceling valid indexing runs via concurrency.
47+
if: ${{ github.repository == 'github/docs-internal' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') }}
4448
runs-on: ubuntu-latest
4549
outputs:
4650
matrix: ${{ steps.set-matrix.outputs.result }}
@@ -55,11 +59,13 @@ jobs:
5559
const allPossible = ["en", ...allNonEnglish]
5660
5761
if (context.eventName === "workflow_run") {
62+
// Job-level `if` already ensures we only get here for successful runs,
63+
// but keep this as a safety check.
5864
if (context.payload.workflow_run.conclusion === "success") {
5965
return ["en"]
6066
}
61-
console.warn(`NOTE! It was a workflow_run but not success ('${context.payload.workflow_run.conclusion}')`)
62-
console.warn("This means we're not going to index anything in the next dependent step.")
67+
// This shouldn't happen due to job-level filter, but handle gracefully.
68+
console.warn(`Unexpected: workflow_run with conclusion '${context.payload.workflow_run.conclusion}'`)
6369
return []
6470
}
6571

.github/workflows/purge-fastly.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ env:
2222

2323
jobs:
2424
send-purges:
25-
# Run when workflow_dispatch is the event (manual) or when deployment_status is the event (automatic) and it's a successful production deploy
25+
# Run when workflow_dispatch is the event (manual) or when deployment_status is the event (automatic) and it's a successful production deploy.
26+
# NOTE: This workflow triggers on all deployment_status events (including staging), but only runs for production.
27+
# Non-production deploys will show as "skipped" - this is expected behavior.
2628
if: >-
2729
${{
2830
github.repository == 'github/docs-internal' &&

0 commit comments

Comments
 (0)