From 40b97119403d8cfeb7da44079b3ef0da4ecfe50a Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 8 Jul 2026 18:30:20 +0800 Subject: [PATCH] Add CI/CD pipeline configuration --- .gitea/workflows/ci.yml | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..342c4a8 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI Pipeline + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + +env: + REGISTRY: git.xiaoxiajianji.com + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + lint-and-build: + name: Lint & Build + runs-on: ubuntu-latest + container: + image: git.xiaoxiajianji.com/xiaoxia/base/node:20 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + run: npm ci + + - name: Code lint + run: npm run lint + + - name: Type check (if applicable) + run: npm run typecheck 2>/dev/null || echo "Typecheck script not found, skipping" + + - name: Build + run: npm run build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + docker-build: + name: Build & Push Docker Image + runs-on: ubuntu-latest + needs: lint-and-build + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + + - name: Set up Docker Buildx + uses: actions/setup-buildx-action@v3 + + - name: Login to Gitea Registry + uses: actions/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Build and push + uses: actions/build-push-action@v6 + with: + context: . + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max