From d8f30e836205bcf3d52b9b99b45c2b83ec6835e3 Mon Sep 17 00:00:00 2001 From: Wang Zhuoxuan Date: Fri, 17 Apr 2026 18:13:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20artifact=20?= =?UTF-8?q?=E4=BC=A0=E9=80=92=EF=BC=8C=E5=90=88=E5=B9=B6=20build+deploy=20?= =?UTF-8?q?jobs=20=E5=85=BC=E5=AE=B9=20Gitea=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy.yml | 92 ++++++++----------------------------- 1 file changed, 20 insertions(+), 72 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 32ab63f..82f23c3 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -2,8 +2,10 @@ # Duoqi API - 双分支工作流(develop → main) # # 工作流: -# develop push → quality → test → build → 自动部署测试环境 -# main push → quality → test → build → 手动确认部署生产环境 +# develop push → quality → test → 构建并自动部署测试环境 +# main push → quality → test → 构建并手动确认部署生产环境 +# +# 注意:单服务器架构,构建后直接部署,无需 artifact 传递 name: CI/CD Pipeline @@ -44,70 +46,21 @@ jobs: - name: Run tests run: bun run test - # ==================== 构建测试镜像 ==================== - build-test: - name: Build Test Image + # ==================== 构建并部署测试环境(develop 自动触发)==================== + build-and-deploy-test: + name: Build & Deploy Test runs-on: ubuntu-latest needs: [quality, test] if: github.ref == 'refs/heads/develop' - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build test image - run: | - docker build --build-arg NODE_ENV=test -t duoqi-api:test . - mkdir -p /tmp/images - docker save duoqi-api:test -o /tmp/images/duoqi-api-test.tar - - - name: Upload image artifact - uses: actions/upload-artifact@v4 - with: - name: docker-images-test - path: /tmp/images/ - retention-days: 1 - - # ==================== 构建生产镜像 ==================== - build-prod: - name: Build Production Image - runs-on: ubuntu-latest - needs: [quality, test] - if: github.ref == 'refs/heads/main' - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build production image - run: | - docker build -t duoqi-api:prod . - mkdir -p /tmp/images - docker save duoqi-api:prod -o /tmp/images/duoqi-api-prod.tar - - - name: Upload image artifact - uses: actions/upload-artifact@v4 - with: - name: docker-images-prod - path: /tmp/images/ - retention-days: 1 - - # ==================== 部署到测试环境(develop push 自动触发) ==================== - deploy-test: - name: Deploy to Test - runs-on: ubuntu-latest - needs: build-test - if: github.ref == 'refs/heads/develop' environment: name: test url: http://test-api.duoqi.me steps: - - name: Download image artifact - uses: actions/download-artifact@v4 - with: - name: docker-images-test - path: /tmp/images/ + - name: Checkout code + uses: actions/checkout@v4 - - name: Load Docker image - run: docker load -i /tmp/images/duoqi-api-test.tar + - name: Build test image + run: docker build --build-arg NODE_ENV=test -t duoqi-api:test . - name: Deploy test environment run: | @@ -128,24 +81,21 @@ jobs: echo "Test environment health check failed" exit 1 - # ==================== 部署到生产环境(main push,手动确认) ==================== - deploy-prod: - name: Deploy to Production + # ==================== 构建并部署生产环境(main 手动确认)==================== + build-and-deploy-prod: + name: Build & Deploy Production runs-on: ubuntu-latest - needs: build-prod + needs: [quality, test] if: github.ref == 'refs/heads/main' environment: name: production url: https://api.duoqi.me steps: - - name: Download image artifact - uses: actions/download-artifact@v4 - with: - name: docker-images-prod - path: /tmp/images/ + - name: Checkout code + uses: actions/checkout@v4 - - name: Load Docker image - run: docker load -i /tmp/images/duoqi-api-prod.tar + - name: Build production image + run: docker build -t duoqi-api:prod . - name: Deploy production run: | @@ -178,6 +128,4 @@ jobs: - name: Cleanup if: always() - run: | - docker image prune -f - rm -rf /tmp/images + run: docker image prune -f