|
12 | 12 | description: "Version to exclusively generate the search index for. E.g. 'dotcom', 'ghes-3.7', 'ghae'"
|
13 | 13 | required: false
|
14 | 14 | default: ''
|
| 15 | + languages: |
| 16 | + description: "Comma separated languages. E.g. 'en,ja, es' (defaults to all)" |
| 17 | + required: false |
| 18 | + default: '' |
15 | 19 | 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 |
17 | 25 |
|
18 | 26 | permissions:
|
19 | 27 | contents: read
|
20 | 28 |
|
21 | 29 | # This allows a subsequently queued workflow run to cancel previous runs
|
22 | 30 | concurrency:
|
23 |
| - group: '${{ github.workflow }} @ ${{ github.head_ref }}' |
| 31 | + group: '${{ github.workflow }} @ ${{ github.head_ref }} ${{ github.event_name }}' |
24 | 32 | cancel-in-progress: true
|
25 | 33 |
|
26 | 34 | env:
|
27 | 35 | FREEZE: ${{ secrets.FREEZE }}
|
28 | 36 | ELASTICSEARCH_URL: ${{ secrets.ELASTICSEARCH_URL }}
|
29 | 37 |
|
30 | 38 | 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 | + |
31 | 82 | updateElasticsearchIndexes:
|
| 83 | + needs: figureOutMatrix |
32 | 84 | name: Update indexes
|
33 | 85 | if: ${{ github.repository == 'github/docs-internal' }}
|
34 | 86 | runs-on: ubuntu-20.04-xl
|
35 | 87 | strategy:
|
36 | 88 | fail-fast: false
|
37 | 89 | max-parallel: 3
|
38 | 90 | 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) }} |
41 | 92 | steps:
|
42 | 93 | - if: ${{ env.FREEZE == 'true' }}
|
43 | 94 | run: |
|
|
0 commit comments