Develop #44
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: Feedback Online System CI | |
| on: | |
| push: | |
| branches: ["main", "develop"] | |
| pull_request: | |
| branches: ["main", "develop"] | |
| jobs: | |
| # 1. JOB CHO BACKEND | |
| backend-ci: | |
| name: Backend Build & Test | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16-alpine | |
| env: | |
| POSTGRES_DB: feedback_online_system_db | |
| POSTGRES_USER: admin | |
| POSTGRES_PASSWORD: password | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "21" | |
| distribution: "temurin" | |
| cache: maven | |
| - name: Build and Run Unit Tests | |
| env: | |
| # Cấu hình DB khớp với Service Postgres ở trên | |
| SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/feedback_online_system_db?currentSchema=public | |
| SPRING_DATASOURCE_USERNAME: admin | |
| SPRING_DATASOURCE_PASSWORD: password | |
| SPRING_MAIL_HOST: smtp.gmail.com | |
| SPRING_MAIL_PORT: 587 | |
| SPRING_MAIL_USERNAME: test@gmail.com | |
| SPRING_MAIL_PASSWORD: fake_password | |
| # Cấu hình Security & JWT từ file yml của bạn | |
| APPLICATION_SECURITY_JWT_SECRET_KEY: 404E635266556A586E3272357538782F413F4428472B4B6250645367566B5970 | |
| APPLICATION_SECURITY_JWT_EXPIRATION: 86400000 | |
| APPLICATION_FRONTEND_URL: "http://localhost:5173" | |
| run: | | |
| cd 01-backend | |
| mvn clean test | |
| - name: Verify Docker Build (Backend) | |
| run: docker build -t feedback-api ./01-backend | |
| # 2. JOB CHO FRONTEND | |
| frontend-ci: | |
| name: Frontend Build & Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: 02-frontend/package-lock.json | |
| - name: Install dependencies | |
| run: | | |
| cd 02-frontend | |
| npm install --legacy-peer-deps | |
| - name: Build Project | |
| run: | | |
| cd 02-frontend | |
| npm run build | |
| - name: Verify Docker Build (Frontend) | |
| run: docker build -t feedback-ui ./02-frontend | |
| # 3. JOB KIỂM TRA TỔNG THỂ DOCKER COMPOSE | |
| docker-compose-check: | |
| name: Docker Compose Validation | |
| needs: [backend-ci, frontend-ci] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate Docker Compose Syntax | |
| run: docker compose config | |
| - name: Dry Run Docker Compose Build | |
| run: docker compose build |