File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const fs = require ( 'fs' )
4+ const core = require ( '@actions/core' )
5+ const eventPayload = JSON . parse ( fs . readFileSync ( process . env . GITHUB_EVENT_PATH , 'utf8' ) )
6+
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
11+
12+ const labelText = 'sync-english-index-for-'
13+ const labelsArray = eventPayload . pull_request . labels
14+
15+ // Find the relevant label
16+ const algoliaLabel = labelsArray . find ( label => label . startsWith ( labelText ) )
17+
18+ // Given: sync-english-index-for-enterprise-server@3.0
19+ // Returns: enterprise-server@3.0
20+ const versionToSync = algoliaLabel . split ( labelText ) [ 1 ]
21+
22+ // Store the version so we can access it later in the workflow
23+ core . setOutput ( 'versionToSync' , versionToSync )
24+ process . exit ( 0 )
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' && startsWith (github.event.label .name, 'sync-english-index-for-')
18+ if : github.repository == 'github/docs-internal' && contains (github.event.pull_request.labels.* .name, 'sync-english-index-for-')
1919 runs-on : ubuntu-latest
2020 steps :
2121 - name : checkout
@@ -34,11 +34,10 @@ jobs:
3434 run : npm ci
3535 - name : Get version from label
3636 id : getVersion
37- run : |
38- echo "::set-output name=version::$(github.event.label.name.split('sync-english-index-for-')[1])"
37+ run : $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-algolia-label.js
3938 - name : Sync English index for single version
4039 env :
41- VERSION : ${{ steps.getVersion.outputs.version }}
40+ VERSION : ${{ steps.getVersion.outputs.versionToSync }}
4241 LANGUAGE : ' en'
4342 ALGOLIA_APPLICATION_ID : ${{ secrets.ALGOLIA_APPLICATION_ID }}
4443 ALGOLIA_API_KEY : ${{ secrets.ALGOLIA_API_KEY }}
You can’t perform that action at this time.
0 commit comments