name: Full CI/CD on: push: branches: [ main ] pull_request: branches: [ main ] jobs: # 后端构建 backend: runs-on: ubuntu-latest services: mysql: image: mysql:8.0 env: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: ry-vue ports: - 3306:3306 redis: image: redis:7 ports: - 6379:6379 steps: - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v4 with: java-version: '11' distribution: 'temurin' cache: maven - name: Build and test run: mvn clean verify - name: Package run: mvn package -DskipTests - name: Upload JAR uses: actions/upload-artifact@v4 with: name: backend-jar path: ruoyi-admin/target/*.jar # 前端构建 frontend: runs-on: ubuntu-latest defaults: run: working-directory: ruoyi-ui-next steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' cache: 'npm' cache-dependency-path: ruoyi-ui-next/package-lock.json - name: Install dependencies run: npm ci - name: Lint run: npm run lint - name: Build run: npm run build - name: Upload dist uses: actions/upload-artifact@v4 with: name: frontend-dist path: ruoyi-ui-next/dist/ # 集成测试 integration-test: needs: [backend, frontend] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Download backend JAR uses: actions/download-artifact@v4 with: name: backend-jar - name: Download frontend dist uses: actions/download-artifact@v4 with: name: frontend-dist - name: Run integration tests run: | echo "Integration tests would run here" echo "Backend JAR and Frontend dist are available" # 部署(仅 main 分支) deploy: needs: [backend, frontend, integration-test] runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - name: Download artifacts uses: actions/download-artifact@v4 - name: Deploy to server run: | echo "Deploy scripts would run here" echo "In production, use SSH or deployment tools" env: DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }} DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}