-
Notifications
You must be signed in to change notification settings - Fork 19
141 lines (125 loc) · 4.44 KB
/
update-nextgen.yml
File metadata and controls
141 lines (125 loc) · 4.44 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Update docs.tidb.io
on:
workflow_dispatch:
inputs:
repo:
description: "Source Repo"
required: true
type: choice
options:
- pingcap/docs
- pingcap/docs-cn
- pingcap/docs-dm
- pingcap/docs-tidb-operator
branch:
description: "Source branch"
type: string
required: true
full:
description: "Full update"
type: boolean
default: false
required: false
env:
BRANCH_MAPPING: "feature/preview-cloud-lake:release-8.5"
EN_CLOUD_BRANCH: feature/preview-cloud-lake
JA_CLOUD_BRANCH: i18n-ja-release-8.5
ZH_CLOUD_BRANCH: i18n-zh-release-8.5
concurrency: ${{ github.workflow }}-${{ inputs.repo }}-${{ inputs.branch }}
jobs:
build:
concurrency: update-${{ inputs.repo }}-${{ inputs.branch }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
ref: nextgen
- uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"
- run: yarn
- name: Init git info
run: |
git status
git config user.name github-actions
git config user.email github-actions@github.com
- name: Update target folder by event input
if: ${{ !inputs.full }}
env:
GITHUB_AUTHORIZATION_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
# handle zh auto translated docs branch(only cloud)
if [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = ${{ env.ZH_CLOUD_BRANCH }} ]
then
yarn download:tidb-cloud:zh --ref ${{ inputs.branch }}
exit 0
fi
# handle ja auto translated docs branch(tidb and cloud)
if [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = ${{ env.JA_CLOUD_BRANCH }} ]
then
yarn download:tidb-cloud:ja --ref ${{ inputs.branch }}
yarn download ${{ inputs.repo }} --ref ${{ inputs.branch }} --branch-mapping "${{ env.BRANCH_MAPPING }}"
exit 0
fi
# handle tidb-cloud doc based on specified en doc branch
if [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = ${{ env.EN_CLOUD_BRANCH }} ]
then
yarn download:tidb-cloud:en --ref ${{ inputs.branch }}
yarn download ${{ inputs.repo }} --ref ${{ inputs.branch }} --branch-mapping "${{ env.BRANCH_MAPPING }}"
exit 0
fi
# docs-dm and docs-tidb-operator need specify language
if [ ${{ inputs.repo }} = "pingcap/docs-dm" ] || [ ${{ inputs.repo }} = "pingcap/docs-tidb-operator" ]
then
yarn download ${{ inputs.repo }} en --ref ${{ inputs.branch }} --branch-mapping "${{ env.BRANCH_MAPPING }}"
yarn download ${{ inputs.repo }} zh --ref ${{ inputs.branch }} --branch-mapping "${{ env.BRANCH_MAPPING }}"
exit 0
fi
yarn download ${{ inputs.repo }} --ref ${{ inputs.branch }} --branch-mapping "${{ env.BRANCH_MAPPING }}"
- name: Update all folder
if: ${{ inputs.full }}
env:
GITHUB_AUTHORIZATION_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
sudo rm -fr ./markdown-pages/*
yarn download:tidb:en:all
yarn download:tidb-cloud:en
yarn download:tidb:zh:all
yarn download:tidb:ja:all
yarn download:tidb-cloud:ja
yarn download:tidb-cloud:zh
yarn download:dm:all
yarn download:tidb-operator:all
- name: Git commit
run: |
git add markdown-pages
git fetch
git pull
if [[ -z $(git status -s) ]]
then
git status
else
git commit -m "update MD by dispatch event ${{ inputs.repo }} ${{ inputs.branch }}"
fi
- name: Git push
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 3
retry_on: error
command: |
git pull --rebase
git push
- name: Trigger website-docs production workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'pingcap',
repo: 'website-docs',
workflow_id: 'production.yml',
ref: 'preview-nextgen',
})