File tree Expand file tree Collapse file tree 1 file changed +74
-0
lines changed
Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy TinyFlow
2+
3+ on :
4+ push :
5+ branches : [master, main]
6+ workflow_dispatch : # 支持手动触发
7+
8+ jobs :
9+ build-and-deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ # 1. 检出代码
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ # 2. 设置 Node.js 环境
18+ - name : Setup Node.js
19+ uses : actions/setup-node@v4
20+ with :
21+ node-version : ' 18'
22+ cache : ' npm'
23+ cache-dependency-path : web/package-lock.json
24+
25+ # 3. 安装前端依赖并构建
26+ - name : Build Frontend
27+ run : |
28+ cd web
29+ npm ci
30+ npm run build
31+
32+ # 4. 设置 Java 环境
33+ - name : Setup Java
34+ uses : actions/setup-java@v4
35+ with :
36+ distribution : ' temurin'
37+ java-version : ' 17'
38+ cache : ' maven'
39+
40+ # 5. 构建后端
41+ - name : Build Backend
42+ run : mvn clean package -DskipTests
43+
44+ # 6. 部署到服务器
45+ - name : Deploy to Server
46+ 47+ with :
48+ host : ${{ secrets.SERVER_HOST }}
49+ port : ${{ secrets.SERVER_PORT }}
50+ username : ${{ secrets.SERVER_USER }}
51+ key : ${{ secrets.SERVER_SSH_KEY }}
52+ script : |
53+ cd /opt/TinyFlow
54+ git pull origin master
55+
56+ # 重新构建前端
57+ cd web
58+ npm ci
59+ npm run build
60+
61+ # 重新构建后端
62+ cd ..
63+ mvn clean package -DskipTests
64+
65+ # 重启服务
66+ systemctl restart tinyflow
67+ systemctl restart nginx
68+
69+ echo " 部署完成!"
70+
71+ # 7. 部署成功通知(可选)
72+ - name : Deployment Success
73+ if : success()
74+ run : echo " TinyFlow 部署成功!"
You can’t perform that action at this time.
0 commit comments