-
Notifications
You must be signed in to change notification settings - Fork 19
136 lines (122 loc) · 4.21 KB
/
update.yml
File metadata and controls
136 lines (122 loc) · 4.21 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
name: Update docs.pingcap.com
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:
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
- 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 tidb doc based on specified ja/cn doc branch
if [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = ${{ env.JA_CLOUD_BRANCH }} ]
then
yarn download:tidb-cloud:ja --ref ${{ inputs.branch }}
exit 0
elif [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = ${{ env.ZH_CLOUD_BRANCH }} ]
then
yarn download:tidb-cloud:zh --ref ${{ inputs.branch }}
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 }}
yarn download ${{ inputs.repo }} zh --ref ${{ inputs.branch }}
else
yarn download ${{ inputs.repo }} --ref ${{ inputs.branch }}
fi
# handle tidb-cloud doc based on specified en doc branch
if [ ${{ inputs.repo }} = "pingcap/docs" ] && [ ${{ inputs.branch }} = "release-8.5" ]
then
yarn download:tidb-cloud:en --ref ${{ inputs.branch }}
fi
- 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 preview
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
https://api.github.com/repos/pingcap/docs-staging/actions/workflows/preview.yml/dispatches \
-d '{"ref":"main","inputs":{}}'
- name: Trigger website-docs
run: |
export CURRENT_SHA=$(git rev-parse HEAD)
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \
https://api.github.com/repos/pingcap/website-docs/actions/workflows/production.yml/dispatches \
-d '{"ref":"master","inputs":{"hash": "$CURRENT_SHA", "fallback": "false"}}'