From 94ee3ae83ba6b93ba22818733841e4b5ab40e784 Mon Sep 17 00:00:00 2001 From: wangxiaowei <1121133807@qq.com> Date: Fri, 24 Apr 2026 15:23:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86Actions=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E7=A7=BB=E5=88=B0=E6=A0=87=E5=87=86=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/main.yml | 129 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 .gitea/workflows/main.yml diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml new file mode 100644 index 0000000..ce1c39a --- /dev/null +++ b/.gitea/workflows/main.yml @@ -0,0 +1,129 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - develop + - master + pull_request: + branches: + - develop + - master + +jobs: + build-dev: + if: github.ref == 'refs/heads/develop' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "18" + registry-url: "https://registry.npmmirror.com" + + - name: Install dependencies + run: npm ci + + - name: Type check + run: npm run type-check || true + + - name: Lint + run: npm run lint || true + + - name: Build + run: npm run build + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: dev-dist + path: dist/ + retention-days: 1 + + deploy-dev: + if: github.ref == 'refs/heads/develop' + needs: build-dev + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: dev-dist + path: dist/ + + - name: Deploy to dev server + uses: appleboy/scp-action@master + with: + host: ${{ secrets.DEV_SERVER_IP }} + username: root + password: ${{ secrets.DEV_SSH_PASSWORD }} + port: 22 + source: "dist/*" + target: ${{ secrets.DEV_SERVER_PATH }} + strip_components: 0 + overwrite: true + command: | + mkdir -p ${{ secrets.DEV_SERVER_PATH }} + chmod 755 ${{ secrets.DEV_SERVER_PATH }} + + build-prod: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "18" + registry-url: "https://registry.npmmirror.com" + + - name: Install dependencies + run: npm ci + + - name: Type check + run: npm run type-check || true + + - name: Lint + run: npm run lint || true + + - name: Build + run: npm run build + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: prod-dist + path: dist/ + retention-days: 7 + + deploy-prod: + if: github.ref == 'refs/heads/master' + needs: build-prod + runs-on: ubuntu-latest + environment: production + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: prod-dist + path: dist/ + + - name: Deploy to prod server + uses: appleboy/scp-action@master + with: + host: ${{ secrets.PROD_SERVER_IP }} + username: root + password: ${{ secrets.PROD_SSH_PASSWORD }} + port: 22 + source: "dist/*" + target: ${{ secrets.PROD_SERVER_PATH }} + strip_components: 0 + overwrite: true + command: | + mkdir -p ${{ secrets.PROD_SERVER_PATH }} + chmod 755 ${{ secrets.PROD_SERVER_PATH }}