Skip to content

Commit 9899e05

Browse files
authored
ci: add deploy-obs-docs (#14)
1 parent 75bd519 commit 9899e05

6 files changed

Lines changed: 77 additions & 6 deletions

File tree

.github/workflows/deploy-github.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
name: Deploy to github.io
1+
name: Deploy home to github.io
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
6+
paths:
7+
- 'packages/common/**'
8+
- 'packages/home/**'
69

710
workflow_dispatch: {}
811

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy docs to Huawei OBS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'packages/opentiny-docs/**'
8+
9+
workflow_dispatch:
10+
11+
env:
12+
# 在 GitHub 项目源码仓库 → 项目的 Settings → Secrets(Actions 里的 Repository secrets) 里提前建好以下变量
13+
HUAWEI_CLOUD_AK: ${{ secrets.HUAWEI_CLOUD_AK }}
14+
HUAWEI_CLOUD_SK: ${{ secrets.HUAWEI_CLOUD_SK }}
15+
HUAWEI_CLOUD_ENDPOINT: ${{ secrets.HUAWEI_CLOUD_ENDPOINT }}
16+
HUAWEI_CLOUD_BUCKET: ${{ secrets.HUAWEI_CLOUD_BUCKET }}
17+
18+
permissions:
19+
contents: read
20+
pages: write
21+
id-token: write
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
- name: Setup pnpm
31+
uses: pnpm/action-setup@v3
32+
with:
33+
version: 9
34+
- name: Install deps
35+
run: pnpm i
36+
- name: Get docs version
37+
run: |
38+
echo "VERSION=$(node -p "require('./packages/opentiny-docs/package.json').version")" >> $GITHUB_ENV
39+
- name: Build docs
40+
run: pnpm -F opentiny-docs build
41+
env:
42+
VITE_BASE: //opentiny-assets.obs.cn-north-4.myhuaweicloud.com/tiny-openTiny-docs/${{ env.VERSION }}/
43+
- name: Copy files
44+
run: |
45+
cp packages/opentiny-docs/dist/index.html packages/opentiny-docs/dist/404.html
46+
# ===== 下载 obsutil =====
47+
- name: Install obsutil
48+
run: |
49+
curl -o obsutil.tar.gz https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz
50+
tar -xzf obsutil.tar.gz
51+
chmod +x obsutil_linux_amd64_*/obsutil
52+
sudo mv obsutil_linux_amd64_*/obsutil /usr/local/bin/obsutil
53+
54+
# ===== 配置并上传 =====
55+
- name: Upload to OBS
56+
run: |
57+
# 一次性配置 AK/SK/endpoint
58+
obsutil config -i=${{ env.HUAWEI_CLOUD_AK }} \
59+
-k=${{ env.HUAWEI_CLOUD_SK }} \
60+
-e=${{ env.HUAWEI_CLOUD_ENDPOINT }}
61+
62+
# 把本地 dist/ 目录整站同步到桶根目录
63+
mv packages/opentiny-docs/dist ${{ env.VERSION }}
64+
obsutil cp ${{ env.VERSION }} obs://${{ env.HUAWEI_CLOUD_BUCKET }}/tiny-openTiny-docs/ -r -f

.github/workflows/deploy-obs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
name: Deploy to Huawei OBS
1+
name: Deploy home to Huawei OBS
22

33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- 'packages/common/**'
8+
- 'packages/home/**'
69

710
workflow_dispatch:
811

packages/opentiny-docs/config/vite.config.base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
}),
3434
],
3535
build: {
36-
outDir: resolve(__dirname, '../dist/openTiny-docs'),
36+
outDir: resolve(__dirname, '../dist'),
3737
commonjsOptions: {
3838
transformMixedEsModules: true,
3939
},

packages/opentiny-docs/config/vite.config.prod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default mergeConfig(
88
{
99
mode: 'docs',
1010
mock: true,
11-
base: `${process.env.static_url_prefix}/tiny-openTiny-docs/${process.env.staticReleaseVersion}/openTiny-docs`,
11+
base: process.env.VITE_BASE || '/',
1212
plugins: [
1313
configCompressPlugin('gzip'),
1414
configVisualizerPlugin(),

packages/opentiny-docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "opentiny-docs",
33
"description": "opentiny docs",
4-
"version": "1.0.0",
4+
"version": "0.1.0",
55
"private": true,
66
"author": "Tiny Team",
77
"license": "MIT",
88
"scripts": {
99
"start": "vite --config ./config/vite.config.dev.ts --port 3101",
1010
"build": "vite build --config ./config/vite.config.prod.ts",
11+
"preview": "vite preview --config ./config/vite.config.prod.ts",
1112
"report": "cross-env REPORT=true npm run build",
1213
"lint-staged": "npx lint-staged"
1314
},

0 commit comments

Comments
 (0)