зеркало из https://github.com/github/docs.git
run the script to check labels at the start of the workflow; exit if none is found
This commit is contained in:
Родитель
f0303416f5
Коммит
8c3be7d8c4
|
@ -4,10 +4,10 @@ const fs = require('fs')
|
|||
const core = require('@actions/core')
|
||||
const eventPayload = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'))
|
||||
|
||||
// This workflow-run script:
|
||||
// 1. Gets an array of labels on a PR
|
||||
// 2. Finds one with the relevant Algolia text
|
||||
// 3. Gets the version substring from the label string
|
||||
// This workflow-run script does the following:
|
||||
// 1. Gets an array of labels on a PR.
|
||||
// 2. Finds one with the relevant Algolia text; if none found, exits early.
|
||||
// 3. Gets the version substring from the label string.
|
||||
|
||||
const labelText = 'sync-english-index-for-'
|
||||
const labelsArray = eventPayload.pull_request.labels
|
||||
|
@ -15,6 +15,11 @@ const labelsArray = eventPayload.pull_request.labels
|
|||
// Find the relevant label
|
||||
const algoliaLabel = labelsArray.find(label => label.startsWith(labelText))
|
||||
|
||||
// Exit early if no relevant label is found
|
||||
if (!algoliaLabel) {
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
// Given: sync-english-index-for-enterprise-server@3.0
|
||||
// Returns: enterprise-server@3.0
|
||||
const versionToSync = algoliaLabel.split(labelText)[1]
|
||||
|
|
|
@ -15,27 +15,32 @@ on:
|
|||
jobs:
|
||||
updateIndices:
|
||||
name: Update English index for single version based on a label's version
|
||||
if: github.repository == 'github/docs-internal' && contains(github.event.pull_request.labels.*.name, 'sync-english-index-for-')
|
||||
if: github.repository == 'github/docs-internal'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
- name: Get version from label if present
|
||||
id: getVersion
|
||||
run: $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-algolia-label.js
|
||||
- if: ${{ steps.getVersion.outputs.versionToSync }}
|
||||
name: checkout
|
||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
||||
- uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d
|
||||
- if: ${{ steps.getVersion.outputs.versionToSync }}
|
||||
uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d
|
||||
with:
|
||||
node-version: 14.x
|
||||
- name: cache node modules
|
||||
- if: ${{ steps.getVersion.outputs.versionToSync }}
|
||||
name: cache node modules
|
||||
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- name: npm ci
|
||||
- if: ${{ steps.getVersion.outputs.versionToSync }}
|
||||
name: npm ci
|
||||
run: npm ci
|
||||
- name: Get version from label
|
||||
id: getVersion
|
||||
run: $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-algolia-label.js
|
||||
- name: Sync English index for single version
|
||||
- if: ${{ steps.getVersion.outputs.versionToSync }}
|
||||
name: Sync English index for single version
|
||||
env:
|
||||
VERSION: ${{ steps.getVersion.outputs.versionToSync }}
|
||||
LANGUAGE: 'en'
|
||||
|
|
Загрузка…
Ссылка в новой задаче