-
Notifications
You must be signed in to change notification settings - Fork 32
86 lines (80 loc) · 2.74 KB
/
deploy-obs.yml
File metadata and controls
86 lines (80 loc) · 2.74 KB
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
name: Deploy to Huawei OBS
on:
push:
branches: [dev]
workflow_dispatch:
inputs:
version:
description: 输入您将要发布的版本号(默认使用 package.json 中的版本号),例如:`0.1.0`。
required: false
type: string
permissions:
contents: read
pages: write
id-token: write
jobs:
# Build job
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install deps
run: npm install --unsafe-perm=true --allow-root --legacy-peer-deps
- name: Get version
id: ver
run: |
# 优先用手动输入的版本号
if [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
else
VERSION="$(node -p "require('./package.json').version")"
fi
echo "version: $VERSION"
echo "value=$VERSION" >> $GITHUB_OUTPUT
- name: Build doc
run: npm run build:opentiny
env:
VITE_OPENTINY_URL_PREFIX: /tiny-charts/
VITE_PUBLISH_URL: //res-static.opentiny.design/tiny-charts-web-doc/${{ steps.ver.outputs.value }}/
- name: Copy files
run: |
cp dist/index.html dist/404.html
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dist-artifact
path: dist/
# Deploy job
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: dist-artifact
path: dist/
- name: Show version
run: |
echo "Deploying version: ${{ needs.build.outputs.version }}"
# ===== 下载 obsutil =====
- name: Install obsutil
run: |
curl -o obsutil.tar.gz https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz
tar -xzf obsutil.tar.gz
chmod +x obsutil_linux_amd64_*/obsutil
sudo mv obsutil_linux_amd64_*/obsutil /usr/local/bin/obsutil
# ===== 配置并上传 =====
- name: Upload to OBS
run: |
# 一次性配置 AK/SK/endpoint
obsutil config -i=${{ secrets.HUAWEI_CLOUD_AK }} \
-k=${{ secrets.HUAWEI_CLOUD_SK }} \
-e=${{ secrets.HUAWEI_CLOUD_ENDPOINT }}
# 把本地 dist/ 目录整站同步到桶根目录
echo "needs.build.outputs.version: ${{ needs.build.outputs.version }}"
mv dist ${{ needs.build.outputs.version }}
obsutil cp ${{ needs.build.outputs.version }} obs://${{ secrets.HUAWEI_CLOUD_BUCKET }}/tiny-charts-web-doc/ -r -f