Skip to content

Commit bb8ccfd

Browse files
authored
ci: add deploy-obs-saas (#3854)
1 parent f503b66 commit bb8ccfd

File tree

1 file changed

+67
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)