fix(ci): 部署链路重构为拉取式,修复工作流问题
Publish Mini Program Dev Version / publish (push) Canceled after 0s
Build and Deploy Server / build (push) Canceled after 0s

- deploy.sh: 目录级原子切换(current.new/current.old)替代 rm -rf 空窗式替换;
  健康检查改为轮询 /api/version HTTP 接口;失败自动回滚上一版本
- 新增 deploy-watch.sh: 服务器本地 systemd timer 轮询 /ci-artifacts 产物指纹,
  发现新版本自动部署——CI 与 AI 不再需要 SSH 到服务器执行任何命令
- server-deploy.yml: 部署包补入 web/ 后台静态资源;移除永不生效的前端构建死代码;
  通知文案如实改为'构建成功'(部署由服务器侧 watcher 完成)
- miniapp-preview.yml: 移除无意义的 --runInBand 测试参数
- 新增 PULL_DEPLOY.md 一次性安装文档(管理员手工执行)
This commit is contained in:
gouki
2026-08-09 00:10:45 +00:00
parent f90b7c7764
commit ec55a1d536
6 changed files with 453 additions and 43 deletions
+6 -19
View File
@@ -62,20 +62,6 @@ jobs:
echo "Version info saved to bin/version.env:"
cat bin/version.env
- name: Build frontend (if exists)
working-directory: server
run: |
if [ -d "web" ]; then
echo "Building frontend..."
cd web
if [ -f "package.json" ]; then
npm ci
npm run build
fi
else
echo "No frontend directory found, skipping frontend build"
fi
- name: Create deployment package
working-directory: server
run: |
@@ -83,8 +69,9 @@ jobs:
cp -r bin/ deploy/
cp -r migrations/ deploy/
cp -r scripts/ deploy/
if [ -d "web/dist" ]; then
cp -r web/dist/ deploy/public/
# 管理后台静态资源必须随包发布(服务以相对路径 ./web 提供)
if [ -d "web" ]; then
cp -r web/ deploy/web/
fi
tar -czf deploy.tar.gz deploy/
@@ -107,8 +94,8 @@ jobs:
run: |
VERSION="1.0.${GITEA_RUN_NUMBER}"
bash .gitea/scripts/notify.sh success \
"后端服务部署成功" \
"版本: v${VERSION}\n部署包: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz"
"后端构建成功" \
"版本: v${VERSION}\n产物: /opt/lunar/ci-artifacts/server-deploy-latest.tar.gz\n部署由服务器侧 watcher 自动拉取完成"
- name: Send failure notification
if: failure()
@@ -118,7 +105,7 @@ jobs:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
bash .gitea/scripts/notify.sh failure \
"后端服务部署失败" \
"后端构建失败" \
"请检查 Actions 日志了解失败原因"
- name: Cleanup