-
Notifications
You must be signed in to change notification settings - Fork 414
117 lines (102 loc) · 3.53 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
name: Deploy Docs
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
on:
push:
tags:
- '*.*.*'
branches:
- master
paths:
- 'docs/**'
jobs:
deploy:
runs-on: ubuntu-latest
if: github.repository_owner == 'lf-edge'
steps:
- name: clone docs
uses: actions/checkout@main
with:
fetch-depth: 0
path: docs-files
- name: clone frontend
uses: actions/checkout@main
with:
repository: 'emqx/emqx-io-docs-frontend'
token: ${{ secrets.CI_GIT_TOKEN }}
ref: next
path: frontend
- name: use python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: use node.js
uses: actions/setup-node@v3
with:
node-version-file: 'frontend/.nvmrc'
- name: use pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: set env
run: |
BRANCH=$(echo ${{ github.ref }} | sed -r "s ^refs/heads/|^refs/tags/(.*) \1 g")
if [ "$BRANCH" = "master" ];then
VERSION="latest"
else
VERSION=$(echo $BRANCH | sed -E 's/([^.]+\.[^.]+).*/\1/')
VERSION="v$VERSION"
fi
echo "DOCS_BRANCH=$BRANCH" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DOCS_TYPE=ekuiper" >> $GITHUB_ENV
- name: remove unused files
run: |
cd docs-files
python3 .github/scripts/remove_unused.py directory.json $(pwd)/docs
- name: move files
run: |
rm frontend/docs/*.md || true
rm frontend/README.md || true
mkdir -p frontend/docs/en/${VERSION}/
mkdir -p frontend/docs/zh/${VERSION}/
mkdir -p frontend/docs/public/api/
cp -r docs-files/docs/en_US/* frontend/docs/en/${VERSION}/
cp -r docs-files/docs/zh_CN/* frontend/docs/zh/${VERSION}/
cp docs-files/docs/directory.json frontend/docs/.vitepress/config/directory.json
- name: generate version config
run: |
cd docs-files
version_list=$(git tag | xargs echo -n)
python3 .github/scripts/generate_version.py $version_list > ../frontend/docs/public/api/${DOCS_TYPE}_versions.json
cat ../frontend/docs/public/api/${DOCS_TYPE}_versions.json
- name: build docs
run: |
cd frontend
pnpm install
pnpm build
- name: upload dist
run: |
cd frontend/docs/.vitepress/
pip3 install coscmd
coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b ekuiper-org-1302406139 -r ap-hongkong
coscmd delete -r -f docs/en/${VERSION} || true
coscmd delete -r -f docs/zh/${VERSION} || true
coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b ekuiper-org-1302406139 -e cos.accelerate.myqcloud.com
coscmd upload -r dist/ /docs/
- name: refresh cdn cache
run: |
pip3 install tccli
tccli configure set secretId ${{ secrets.TENCENT_COS_ID }}
tccli configure set secretKey ${{ secrets.TENCENT_COS_KEY }}
tccli configure set region ap-hongkong
tccli cdn PurgePathCache --Paths '["https://ekuiper.org/docs/", "https://ekuiper-docs.emqx.net/"]' --FlushType delete
- name: update search index
uses: Swilder-M/docsearch-scraper-simple@next
env:
APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID }}
API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
with:
docs_type: ${{ env.DOCS_TYPE }}
docs_version: ${{ env.VERSION }}