File tree Expand file tree Collapse file tree 1 file changed +104
-0
lines changed
Expand file tree Collapse file tree 1 file changed +104
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : main
6+ pull_request :
7+ branches : main
8+
9+ env :
10+ NODE_VERSION : ' 20'
11+ BUCKET : #
12+ ENDPOINT : #
13+ CI : true
14+
15+ jobs :
16+ lint-and-test :
17+ name : 代码检查和测试
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - name : 检出代码
22+ uses : actions/checkout@v4
23+
24+ - name : 安装 pnpm
25+ uses : pnpm/action-setup@v4
26+ with :
27+ version : 8
28+
29+ - name : 设置 Node.js
30+ uses : actions/setup-node@v4
31+ with :
32+ node-version : ${{ env.NODE_VERSION }}
33+ cache : ' pnpm'
34+
35+ - name : 安装依赖
36+ run : pnpm install --no-frozen-lockfile
37+
38+ - name : 代码格式检查
39+ run : pnpm format
40+
41+ - name : 代码质量检查
42+ run : pnpm lint
43+
44+ - name : 类型检查
45+ run : pnpm type-check
46+
47+ - name : 构建项目
48+ run : pnpm build
49+
50+ - name : 上传构建产物
51+ uses : actions/upload-artifact@v4
52+ with :
53+ name : dist
54+ path : dist/
55+ retention-days : 1
56+
57+ deploy :
58+ name : deploy to OSS
59+ runs-on : ubuntu-latest
60+ needs : lint-and-test
61+ if : github.ref == 'refs/heads/main'
62+
63+ steps :
64+ - name : 检出代码
65+ uses : actions/checkout@v4
66+
67+ - name : 安装 pnpm
68+ uses : pnpm/action-setup@v4
69+ with :
70+ version : 8
71+
72+ - name : 设置 Node.js
73+ uses : actions/setup-node@v4
74+ with :
75+ node-version : ${{ env.NODE_VERSION }}
76+ cache : ' pnpm'
77+
78+ - name : 安装依赖
79+ run : pnpm install --no-frozen-lockfile
80+
81+ - name : 构建项目
82+ run : pnpm build
83+
84+ - name : 配置阿里云OSS CLI
85+ uses : manyuanrong/setup-ossutil@master
86+ with :
87+ endpoint : ${{ env.ENDPOINT }}
88+ access-key-id : ${{ # }}
89+ access-key-secret : ${{ # }}
90+
91+ - name : 上传到OSS
92+ run : |
93+ # 同步构建产物到OSS
94+ ossutil cp -rf dist/ oss://${{ env.BUCKET }}/
95+
96+
97+ - name : 清理缓存
98+ run : |
99+ # 清理OSS中的旧文件
100+ # ossutil ls oss://${{ env.ENDPOINT }}/ | grep -E "\.(js|css|html)$" | head -n -10 | xargs -I {} ossutil rm {}
101+
102+ - name : 部署完成通知
103+ run : |
104+ echo "✅ 部署完成!"
You can’t perform that action at this time.
0 commit comments