-
Notifications
You must be signed in to change notification settings - Fork 59
131 lines (113 loc) · 4.06 KB
/
deploy.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
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
name: Deploy
on:
push:
branches:
- main
jobs:
Prepare:
name: Setup environment
if: ${{ github.event.label.name != 'no-build' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repsitory
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 1
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7.17
- name: Cache Python packages
id: cache-python
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}$-${{ hashFiles('requirements.txt') }}
- name: Install MegEngine and Python dependencies
if: steps.cache-python.outputs.cache-hit != 'true'
run: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
pip install megengine -f https://megengine.org.cn/whl/mge.html
Generate:
name: Build HTML files
needs: Prepare
runs-on: ubuntu-latest
strategy:
matrix:
language: ["zh_CN", "en"]
steps:
- name: Checkout repsitory
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 1
submodules: recursive
- name: LFS - Create hash files
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: LFS - Restore cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ hashFiles('.lfs-assets-id') }}
- name: LFS - pull missed files
run: git lfs pull
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7.17
- name: Get cached Python packages
id: cache-python
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}$-${{ hashFiles('requirements.txt') }}
- name: Install pandoc and other dependencies
run: sudo apt install -y pandoc graphviz
- name: Generate HTML files
run: |
make LANGUAGE=${{ matrix.language }} html
mv build/html ${{ matrix.language }}
tar czf ${{ matrix.language }}.tgz ${{ matrix.language }}
- name: Upload aritifacts
uses: actions/upload-artifact@v2
with:
name: HTML
path: ${{ matrix.language }}.tgz
Deploy:
name: Deploy on OSS
needs: Generate
runs-on: ubuntu-20.04
steps:
- name: Checkout repsitory
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 1
lfs: true
- name: Download aritifacts
uses: actions/download-artifact@v2
with:
name: HTML
- name: Deploy on OSS
run: |
tar xzf zh_CN.tgz && mv zh_CN zh
tar xzf en.tgz
tar czf static.tgz zh en
export GIT_HASH=$(git rev-parse --short HEAD) && echo $GIT_HASH
wget http://gosspublic.alicdn.com/ossutil/1.7.7/ossutil64
chmod 755 ossutil64
./ossutil64 config -e ${{ secrets.OSS_PROD_ENDPOINT }} -i ${{ secrets.OSS_PROD_ACCESS_KEY_ID }} -k ${{ secrets.OSS_PROD_ACCESS_KEY_SECRET }}
./ossutil64 mkdir oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/commit-$GIT_HASH
./ossutil64 cp static.tgz oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/commit-$GIT_HASH/static.tgz
./ossutil64 cp -f oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/mapping.json .
export MGE_DOC_MODE="MINI"
version=`python3 -c "from source.conf import version; print(version)"`
python3 scripts/oss/update.py -v ${version} -c ${GIT_HASH}
python3 scripts/oss/update.py -v "stable" -c ${GIT_HASH}
python3 scripts/oss/gen_version.py
./ossutil64 cp -f version.json oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/version.json
./ossutil64 cp -f mapping.json oss://${{ secrets.OSS_PROD_BUCKET }}/documentation/mapping.json