test be start z #37
This file contains 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/CD Pipeline | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build_backend: | |
name: Build backend and connect to Postgres DB | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_DB: measdb | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '20' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml -DskipTests | |
working-directory: backend | |
- name: Check PostgreSQL connection | |
run: | | |
sleep 10 | |
PGPASSWORD="${{ secrets.POSTGRES_PASSWORD }}" psql -h localhost -U "${{ secrets.POSTGRES_USER }}" -d postgres -c "SELECT 1;" | |
continue-on-error: true # Continue with the workflow even if the PostgreSQL connection test fails | |
start_backend: | |
runs-on: ubuntu-latest | |
needs: [build_backend] | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '20' | |
cache: maven | |
- name: Start backend | |
run: ./mvnw quarkus:dev | |
working-directory: backend | |
build_frontend: | |
runs-on: ubuntu-latest | |
needs: [build_backend] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: frontend/package-lock.json | |
- name: Install dependencies | |
run: npm ci | |
working-directory: frontend | |
- name: Build frontend | |
run: npm run build --no-progress 2>&1 >/dev/null || true | |
working-directory: frontend |