chore(deploy): 修复生产环境关键问题并增强系统功能 #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI (Build + Lint + Test) | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| jobs: | |
| backend-lint: | |
| name: Backend Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./backend | |
| run: npm ci | |
| - name: Run TypeScript check | |
| working-directory: ./backend | |
| run: npx tsc --noEmit | |
| - name: Run ESLint | |
| working-directory: ./backend | |
| run: npm run lint --if-present | |
| continue-on-error: true | |
| frontend-lint: | |
| name: Frontend Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./frontend | |
| run: npm ci | |
| - name: Run TypeScript check | |
| working-directory: ./frontend | |
| run: npx tsc --noEmit | |
| - name: Run ESLint | |
| working-directory: ./frontend | |
| run: npm run lint --if-present | |
| continue-on-error: true | |
| backend-test: | |
| name: Backend Test | |
| runs-on: ubuntu-latest | |
| needs: [backend-lint] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./backend | |
| run: npm ci | |
| - name: Run tests | |
| working-directory: ./backend | |
| run: npm test --if-present | |
| env: | |
| JWT_SECRET: test-secret-for-ci | |
| DOUBAO_API_KEY: test-api-key | |
| frontend-build: | |
| name: Frontend Build | |
| runs-on: ubuntu-latest | |
| needs: [frontend-lint] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./frontend | |
| run: npm ci | |
| - name: Build | |
| working-directory: ./frontend | |
| run: npm run build | |
| docker-build: | |
| name: Docker Build (Verify) | |
| runs-on: ubuntu-latest | |
| needs: [backend-test, frontend-build] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Backend (verify only) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: docker/Dockerfile.backend | |
| push: false | |
| load: true | |
| tags: itops-backend:ci-test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build Frontend (verify only) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: docker/Dockerfile.frontend | |
| push: false | |
| load: true | |
| tags: itops-frontend:ci-test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |