-
Notifications
You must be signed in to change notification settings - Fork 64
131 lines (113 loc) · 4.17 KB
/
deploy-docs.yaml
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
name: Deploy Docs
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
on:
push:
tags:
- "*"
jobs:
deploy:
strategy:
fail-fast: false
matrix:
ref:
- "latest"
- ""
runs-on: ubuntu-20.04
if: github.repository_owner == 'emqx'
steps:
- name: clone docs
uses: actions/checkout@v2
with:
fetch-depth: 0
path: docs-files
- name: clone frontend
uses: actions/checkout@v2
with:
repository: 'emqx/docs-emqx-com-frontend'
token: ${{ secrets.CI_GIT_TOKEN }}
path: frontend
- name: use node.js
uses: actions/setup-node@v1
with:
node-version: 14.15
- name: use python
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: set env
run: |
if [ "${{ matrix.ref }}" == "latest" ]; then
echo "VERSION=latest" >> $GITHUB_ENV
else
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
fi
echo "DOCS_TYPE=emqx-operator" >> $GITHUB_ENV
- name: remove unused files
run: |
cd docs-files
python3 .github/scripts/remove_unused.py $(pwd)/docs
- name: move files
run: |
rm frontend/docs/en/README.md || true
rm frontend/docs/zh/README.md || true
rm frontend/docs/*.md || true
rm frontend/README.md
mkdir -p frontend/docs/en/${DOCS_TYPE}/${VERSION}/
mkdir -p frontend/docs/zh/${DOCS_TYPE}/${VERSION}/
mkdir -p frontend/docs/.vuepress/public/api/
cp -r docs-files/docs/en_US/* frontend/docs/en/${DOCS_TYPE}/${VERSION}/
cp -r docs-files/docs/zh_CN/* frontend/docs/zh/${DOCS_TYPE}/${VERSION}/
cp docs-files/docs/directory.json frontend/docs/.vuepress/config/directory.json
cd docs-files && git tag -l | egrep "^[1-9]\.[0-9]\.[0-9]?" | jq -R -s -c 'split("\n")[:-1] | . += ["latest"] | reverse' > ../frontend/docs/.vuepress/public/api/${DOCS_TYPE}_versions.json
- name: build docs
run: |
cd frontend
yarn && yarn build
- name: upload dist
run: |
pip3 install coscmd
coscmd config -a ${{ secrets.COS_ID }} -s ${{ secrets.COS_KEY }} -b ${{ secrets.COS_NAME }} -r ${{ secrets.COS_REGION }}
coscmd delete -r -f en/${DOCS_TYPE}/${VERSION} || true
coscmd delete -r -f zh/${DOCS_TYPE}/${VERSION} || true
coscmd config -a ${{ secrets.COS_ID }} -s ${{ secrets.COS_KEY }} -b ${{ secrets.COS_NAME }} -e cos.accelerate.myqcloud.com
cd frontend/docs/.vuepress/dist/
zip -rq docs-dist-${DOCS_TYPE}-${VERSION}.zip ./
coscmd upload docs-dist-${DOCS_TYPE}-${VERSION}.zip docs-zip/
sleep 90
- name: flush cdn
run: |
pip3 install tccli
tccli configure set secretId ${{ secrets.COS_ID }}
tccli configure set secretKey ${{ secrets.COS_KEY }}
tccli configure set region ${{ secrets.COS_REGION }}
tccli cdn PurgePathCache --cli-unfold-argument --Paths https://docs.emqx.com/zh/${DOCS_TYPE}/${VERSION}/ https://docs.emqx.com/en/${DOCS_TYPE}/${VERSION}/ --FlushType delete
tccli cdn PurgeUrlsCache --cli-unfold-argument --Urls https://docs.emqx.com/api/${DOCS_TYPE}_versions.json https://docs.emqx.com/sitemap_${DOCS_TYPE}_${VERSION}.xml
- name: clone docsearch
uses: actions/checkout@v2
with:
repository: 'Swilder-M/docsearch-scraper-simple'
path: docsearch
- name: install pipenv
run: |
python -m pip install --upgrade pipenv wheel
- id: cache-pipenv
uses: actions/cache@v1
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
- name: install dependencies
if: steps.cache-pipenv.outputs.cache-hit != 'true'
run: |
cd docsearch
pipenv install --keep-outdated
- name: update current version
if: env.VERSION == 'latest'
env:
APPLICATION_ID: ${{ secrets.DOCS_APPLICATION_ID }}
API_KEY: ${{ secrets.DOCS_API_KEY }}
run: |
cd docsearch
pipenv run python -m src.index config ${DOCS_TYPE} ${VERSION}