Skip to content

Commit a658163

Browse files
authored
Merge pull request #22417 from github/repo-sync
repo sync
2 parents 3054b5b + 16548aa commit a658163

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

.github/workflows/sync-search-elasticsearch.yml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,83 @@ on:
1212
description: "Version to exclusively generate the search index for. E.g. 'dotcom', 'ghes-3.7', 'ghae'"
1313
required: false
1414
default: ''
15+
languages:
16+
description: "Comma separated languages. E.g. 'en,ja, es' (defaults to all)"
17+
required: false
18+
default: ''
1519
schedule:
16-
- cron: '20 */4 * * *' # Run every 4 hours at 20 minutes after
20+
- cron: '20 */24 * * *' # Run every 24 hours at 20 minutes past the hour
21+
workflow_run:
22+
workflows: ['Azure Production - Build and Deploy']
23+
types:
24+
- completed
1725

1826
permissions:
1927
contents: read
2028

2129
# This allows a subsequently queued workflow run to cancel previous runs
2230
concurrency:
23-
group: '${{ github.workflow }} @ ${{ github.head_ref }}'
31+
group: '${{ github.workflow }} @ ${{ github.head_ref }} ${{ github.event_name }}'
2432
cancel-in-progress: true
2533

2634
env:
2735
FREEZE: ${{ secrets.FREEZE }}
2836
ELASTICSEARCH_URL: ${{ secrets.ELASTICSEARCH_URL }}
2937

3038
jobs:
39+
figureOutMatrix:
40+
runs-on: ubuntu-latest
41+
outputs:
42+
matrix: ${{ steps.set-matrix.outputs.result }}
43+
steps:
44+
- uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
45+
id: set-matrix
46+
with:
47+
script: |
48+
// Edit this list for the definitive list of languages
49+
// (other than English) we want to index in Elasticsearch.
50+
const allNonEnglish = ["ja", "es", "pt", "cn", "ru", "fr", "ko", "de"]
51+
const allPossible = ["en", ...allNonEnglish]
52+
53+
if (context.eventName === "workflow_run") {
54+
if (context.payload.workflow_run.conclusion === "success") {
55+
return ["en"]
56+
}
57+
throw new Error(`It was a workflow_run but not success ('${context.payload.workflow_run.conclusion}')`)
58+
}
59+
60+
if (context.eventName === "workflow_dispatch") {
61+
if (context.payload.inputs.languages) {
62+
const clean = context.payload.inputs.languages.split(',').map(x => x.trim()).filter(Boolean)
63+
const notRecognized = clean.find(x => !allPossible.includes(x))
64+
if (notRecognized) {
65+
throw new Error(`'${notRecognized}' is not a recognized language code`)
66+
}
67+
return clean
68+
}
69+
return allPossible
70+
}
71+
72+
if (context.eventName === "schedule") {
73+
return allNonEnglish
74+
}
75+
76+
console.log(context)
77+
throw new Error(`Unable figure out what languages to run (${context.eventName})`)
78+
79+
- name: Debug output
80+
run: echo "${{ steps.set-matrix.outputs.result }}"
81+
3182
updateElasticsearchIndexes:
83+
needs: figureOutMatrix
3284
name: Update indexes
3385
if: ${{ github.repository == 'github/docs-internal' }}
3486
runs-on: ubuntu-20.04-xl
3587
strategy:
3688
fail-fast: false
3789
max-parallel: 3
3890
matrix:
39-
# This needs to match the languages we support
40-
language: [en, ja, es, pt, cn, ru, fr, ko, de]
91+
language: ${{ fromJSON(needs.figureOutMatrix.outputs.matrix) }}
4192
steps:
4293
- if: ${{ env.FREEZE == 'true' }}
4394
run: |

0 commit comments

Comments
 (0)