From 65718a8460b07a29b003b8d4a94d9705e0d5a835 Mon Sep 17 00:00:00 2001 From: hhs <386998068@qq.com> Date: Sun, 14 Jun 2026 13:38:35 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=20Gitea=20Actions=20?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PR 到 main 时验证 Docker 镜像构建 - push 到 main 时自动构建并部署,含健康检查 --- .gitea/workflows/deploy.yml | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..540e850 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: Deploy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + # ---- PR 时:验证 Docker 镜像可构建 ---- + verify: + if: github.event_name == 'pull_request' + runs-on: aliyun + steps: + - name: Checkout + uses: "http://8.161.227.145:3000/huanghaosheng/checkout@releases/v4" + + - name: Verify Frontend Build + run: docker build -t camtalk-frontend-test ./frontend + + - name: Verify Backend Build + run: docker build -t camtalk-backend-test ./backend + + - name: Cleanup + run: | + docker rmi camtalk-frontend-test camtalk-backend-test || true + + # ---- push main 时:构建并部署 ---- + deploy: + if: github.event_name == 'push' + runs-on: aliyun + steps: + - name: Checkout + uses: "http://8.161.227.145:3000/huanghaosheng/checkout@releases/v4" + + - name: Build and Deploy + run: | + chmod +x deploy.sh + ./deploy.sh build + ./deploy.sh restart + + - name: Health Check + run: | + for i in $(seq 1 10); do + if curl -sf http://localhost/api/health > /dev/null 2>&1; then + echo "服务启动成功" + exit 0 + fi + echo "等待服务启动... ($i/10)" + sleep 3 + done + echo "服务启动超时" + exit 1