-
Notifications
You must be signed in to change notification settings - Fork 5
142 lines (121 loc) · 4.38 KB
/
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
132
133
134
135
136
137
138
139
140
141
142
name: Check, render and publish docs
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
main-release-for-github-pages:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: "yarn"
cache-dependency-path: "./yarn.lock"
- name: Install yarn
run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-docs-dir-path
run: |
echo "::set-output name=dir::"
yarn cache dir
- uses: actions/cache@v3
id: yarn-cache-docs
with:
path: |
${{ steps.yarn-cache-docs-dir-path.outputs.dir }}
**/node_modules
key: ${{ runner.os }}-yarn-docs-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-docs-
- name: Install docs dependencies
if: steps.yarn-cache-docs.outputs.cache-hit != 'true' # Over here!
run: make install-req
- name: Checkout gh-pages branch for archived versions docs
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
sparse-checkout: |
.archived-versions
- name: Copy archived version files
run: |
[ ! -d gh-pages/.archived-versions ] && exit 0
cp gh-pages/.archived-versions/versions.json ./
cp -R gh-pages/.archived-versions/versioned_sidebars ./
cp -R gh-pages/.archived-versions/versioned_docs ./
cp -R gh-pages/.archived-versions/i18n/zh/docusaurus-plugin-content-docs/version-* ./i18n/zh/docusaurus-plugin-content-docs/
- name: Lint docs
run: make lint-docs
- name: Build docs
run: make build-docs
- name: Update archived version files
if: ${{ github.ref == 'refs/heads/main'}}
run: |
mkdir -p build/.archived-versions
cp versions.json build/.archived-versions/
cp -R versioned_sidebars build/.archived-versions/
cp -R versioned_docs build/.archived-versions/
mkdir -p build/.archived-versions/i18n/zh/docusaurus-plugin-content-docs
cp -R i18n/zh/docusaurus-plugin-content-docs/version-* build/.archived-versions/i18n/zh/docusaurus-plugin-content-docs/
- name: Publish to Github Pages
if: ${{ github.ref == 'refs/heads/main'}}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
user_name: github-actions[bot]
cname: doc.starwhale.ai
user_email: "github-actions[bot]@users.noreply.github.com"
main-release-for-starwhale-cn:
runs-on: self-hosted
needs:
- main-release-for-github-pages
if: ${{ github.ref == 'refs/heads/main'}}
steps:
- uses: actions/checkout@v3
- name: Install docs dependencies
run: |
yarn config set registry https://registry.npmmirror.com
npm config set registry https://registry.npm.taobao.org
make install-req
- name: Checkout gh-pages branch for archived versions docs
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
sparse-checkout: |
.archived-versions
- name: Copy archived version files
run: |
[ ! -d gh-pages/.archived-versions ] && exit 0
cp gh-pages/.archived-versions/versions.json ./
cp -R gh-pages/.archived-versions/versioned_sidebars ./
cp -R gh-pages/.archived-versions/versioned_docs ./
cp -R gh-pages/.archived-versions/i18n/zh/docusaurus-plugin-content-docs/version-* ./i18n/zh/docusaurus-plugin-content-docs/
- name: Build docs
run: make build-docs
env:
DEFAULT_LOCALE: "zh"
URL: "https://starwhale.cn"
ORG: "starwhale.cn"
BASE_URL: "/docs/"
- name: Publish docs
uses: appleboy/[email protected]
with:
debug: true
host: ${{ secrets.DOC_RELEASE_HOST }}
username: ${{ secrets.DOC_RELEASE_USER }}
key: ${{ secrets.DOC_RELEASE_KEY }}
source: "build/*"
target: "/data/www/starwhale-cn-docs/docs/"
strip_components: 1
rm: true