forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (73 loc) · 3.14 KB
/
enterprise-release-sync-search-index.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Enterprise Server Release Search Sync
# **What it does**: This workflow is used during the Enterprise Server release
# process. The Enterprise release checklist includes a step to add a label in
# the format `sync-english-index-for-enterprise-server@<RELEASE NUMBER>`. When
# that label is added, this workflow runs anytime new commits are made to the
# Enterprise release megabranch. The Docubot user commits the search indexes in
# the `lib/search/indexes` directory.
#
# **Why we have it**: The Lunr index for the next Enterprise release doesn't yet
# exist, so we need to generate it. Search wouldn't work at all if we shipped
# the new release without shipping the index for that release at the same time.
#
# **Who does it impact**: The DRI for the Enterprise release, the content
# writers that are a part of the release and the docs-engineering DRI.
on:
workflow_dispatch:
pull_request:
types:
- labeled
- unlabeled
- opened
- reopened
- synchronize
- ready_for_review
- unlocked
# This workflow requires a label in the format `sync-english-index-for-<PLAN@RELEASE>`
jobs:
updateIndices:
name: Update English index for new GHES release
# Skip this check if the event originated from Docubot, to prevent
# infinite runs when Docubot checks in the search indexes in this workflow
if: github.repository == 'github/docs-internal' && github.event.sender.login != 'Docubot'
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.DOCUBOT_REPO_PAT }}
- name: Setup Node
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f
with:
node-version: 16.8.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Get GHES release number from search label if present; only continue if the label is found.
id: getVersion
run: $GITHUB_WORKSPACE/.github/actions-scripts/enterprise-search-label.js
- name: Generate the search index files
if: ${{ steps.getVersion.outputs.versionToSync }}
env:
VERSION: ${{ steps.getVersion.outputs.versionToSync }}
LANGUAGE: 'en'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build
npm run sync-search
- name: Commit the index files and push LFS objects
if: ${{ steps.getVersion.outputs.versionToSync }}
run: |
echo 'git config user.name Docubot'
git config user.name Docubot
echo 'git config user.email 67483024+docubot@users.noreply.github.com'
git config user.email 67483024+docubot@users.noreply.github.com
echo 'git add lib/search/indexes'
git add lib/search/indexes/*
echo 'git commit -m "update search indexes"'
git commit -m 'update search indexes'
echo 'git lfs push --all origin'
git lfs push --all origin
echo 'git push origin' $GITHUB_HEAD_REF '--set-upstream'
git push origin $GITHUB_HEAD_REF --set-upstream