File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,17 +4,22 @@ const fs = require('fs')
44const core = require ( '@actions/core' )
55const eventPayload = JSON . parse ( fs . readFileSync ( process . env . GITHUB_EVENT_PATH , 'utf8' ) )
66
7- // This workflow-run script:
8- // 1. Gets an array of labels on a PR
9- // 2. Finds one with the relevant Algolia text
10- // 3. Gets the version substring from the label string
7+ // This workflow-run script does the following :
8+ // 1. Gets an array of labels on a PR.
9+ // 2. Finds one with the relevant Algolia text; if none found, exits early.
10+ // 3. Gets the version substring from the label string.
1111
1212const labelText = 'sync-english-index-for-'
1313const labelsArray = eventPayload . pull_request . labels
1414
1515// Find the relevant label
1616const algoliaLabel = labelsArray . find ( label => label . startsWith ( labelText ) )
1717
18+ // Exit early if no relevant label is found
19+ if ( ! algoliaLabel ) {
20+ process . exit ( 0 )
21+ }
22+
1823// Given: sync-english-index-for-enterprise-server@3.0
1924// Returns: enterprise-server@3.0
2025const versionToSync = algoliaLabel . split ( labelText ) [ 1 ]
Original file line number Diff line number Diff line change 1515jobs :
1616 updateIndices :
1717 name : Update English index for single version based on a label's version
18- if : github.repository == 'github/docs-internal' && contains(github.event.pull_request.labels.*.name, 'sync-english-index-for-')
18+ if : github.repository == 'github/docs-internal'
1919 runs-on : ubuntu-latest
2020 steps :
21- - name : checkout
21+ - name : Get version from label if present
22+ id : getVersion
23+ run : $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-algolia-label.js
24+ - if : ${{ steps.getVersion.outputs.versionToSync }}
25+ name : checkout
2226 uses : actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
23- - uses : actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d
27+ - if : ${{ steps.getVersion.outputs.versionToSync }}
28+ uses : actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d
2429 with :
2530 node-version : 14.x
26- - name : cache node modules
31+ - if : ${{ steps.getVersion.outputs.versionToSync }}
32+ name : cache node modules
2733 uses : actions/cache@0781355a23dac32fd3bac414512f4b903437991a
2834 with :
2935 path : ~/.npm
3036 key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
3137 restore-keys : |
3238 ${{ runner.os }}-node-
33- - name : npm ci
39+ - if : ${{ steps.getVersion.outputs.versionToSync }}
40+ name : npm ci
3441 run : npm ci
35- - name : Get version from label
36- id : getVersion
37- run : $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-algolia-label.js
38- - name : Sync English index for single version
42+ - if : ${{ steps.getVersion.outputs.versionToSync }}
43+ name : Sync English index for single version
3944 env :
4045 VERSION : ${{ steps.getVersion.outputs.versionToSync }}
4146 LANGUAGE : ' en'
You can’t perform that action at this time.
0 commit comments