1414 branches :
1515 - master
1616 - web-refactor
17+ paths :
18+ - ' OpenBlog-business/**'
19+ - ' OpenBlog-framework*/**'
20+ - ' vue/**'
21+ - ' pom.xml'
22+ - ' .github/workflows/ci.yml'
1723
1824jobs :
19- build-and-deploy :
25+ # 检测变更范围,供后续 job 条件判断
26+ changes :
27+ runs-on : ubuntu-latest
28+ outputs :
29+ backend : ${{ steps.filter.outputs.backend }}
30+ frontend : ${{ steps.filter.outputs.frontend }}
31+ steps :
32+ - uses : actions/checkout@v4
33+ - uses : dorny/paths-filter@v3
34+ id : filter
35+ with :
36+ filters : |
37+ backend:
38+ - 'OpenBlog-business/**'
39+ - 'OpenBlog-framework*/**'
40+ - 'pom.xml'
41+ frontend:
42+ - 'vue/**'
43+
44+ build-backend :
45+ needs : changes
46+ if : ${{ needs.changes.outputs.backend == 'true' }}
2047 runs-on : ubuntu-latest
21- # 消除 “Node.js 20 actions are deprecated” 警告:让基于 JS 的 action 在 Node 24 上跑
22- # 见 https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
2348 env :
2449 FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
2550
3762 - name : Build backend (Maven)
3863 run : mvn -B -ntp package -DskipTests -pl OpenBlog-business -am
3964
65+ build-frontend :
66+ needs : changes
67+ if : ${{ needs.changes.outputs.frontend == 'true' }}
68+ runs-on : ubuntu-latest
69+ env :
70+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
71+
72+ steps :
73+ - name : Checkout
74+ uses : actions/checkout@v4
75+
4076 - name : Set up Node.js
4177 uses : actions/setup-node@v4
4278 with :
@@ -56,12 +92,29 @@ jobs:
5692 cp -r vue/dist release/dist
5793 cp vue/Dockerfile vue/docker.sh vue/nginx.conf release/
5894
59- # 在 GitHub Runner 构建镜像并导出,避免国内服务器直连 Docker Hub 拉取 nginx:alpine 超时
6095 - name : Build Docker image on runner
6196 run : |
6297 docker build -t openblog-web release/
6398 docker save openblog-web | gzip > release/openblog-web.tar.gz
6499
100+ - name : Upload release bundle
101+ uses : actions/upload-artifact@v4
102+ with :
103+ name : release-frontend
104+ path : release/
105+
106+ deploy-frontend :
107+ needs : build-frontend
108+ if : ${{ needs.build-frontend.result == 'success' }}
109+ runs-on : ubuntu-latest
110+
111+ steps :
112+ - name : Download release bundle
113+ uses : actions/download-artifact@v4
114+ with :
115+ name : release-frontend
116+ path : release/
117+
65118 - name : Deploy files to server
66119 uses : easingthemes/ssh-deploy@v5.1.1
67120 with :
0 commit comments