add env in CI #8
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 workflow | ||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| jobs: | ||
| backend: | ||
| name: Build & Test Backend | ||
| runs-on: ubuntu-latest | ||
| services: | ||
| postgres: | ||
| image: postgres:16 | ||
| env: | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_PASSWORD: postgres | ||
| POSTGRES_DB: springreact | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd="pg_isready -U postgres" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=5 | ||
| environment: | ||
| SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/springreact | ||
| SPRING_DATASOURCE_USERNAME: postgres | ||
| SPRING_DATASOURCE_PASSWORD: postgres | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| - name: Set up Java | ||
| uses: actions/setup-java@v3 | ||
| with: | ||
| distribution: temurin | ||
| java-version: '21' | ||
| - name: Build backend with Maven | ||
| working-directory: backend | ||
| run: mvn clean package | ||
| - name: Run backend tests | ||
| working-directory: backend | ||
| run: mvn test | ||
| frontend: | ||
| name: Build & Lint Frontend | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: '20' | ||
| - name: Install frontend dependencies | ||
| working-directory: frontend | ||
| run: npm install | ||
| - name: Lint frontend | ||
| working-directory: frontend | ||
| run: npm run lint | ||
| - name: Build frontend | ||
| working-directory: frontend | ||
| run: npm run build | ||
| docker: | ||
| name: Docker Build Check | ||
| runs-on: ubuntu-latest | ||
| needs: [backend,frontend] | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
| - name: Build Docker images | ||
| run: docker compose build | ||