name: CI on: push: branches: [main] pull_request: # A newer push to the same branch makes the older run pointless. concurrency: group: ci-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: checks: name: Lint, types, build, tests runs-on: ubuntu-latest timeout-minutes: 15 services: postgres: image: postgres:19-alpine env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: electro4ort ports: - 5432:5432 options: >- --health-cmd "pg_isready -U postgres -d electro4ort" --health-interval 5s --health-timeout 5s --health-retries 10 redis: image: redis:8-alpine ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 5s --health-timeout 5s --health-retries 10 env: # What apps/api needs to start; the e2e tests run against the services # above. Nothing here is used outside this run. DATABASE_URL: postgres://postgres:postgres@localhost:5432/electro4ort REDIS_URL: redis://localhost:6379 BETTER_AUTH_URL: http://localhost:3001 TRUSTED_ORIGINS: http://localhost:3000 steps: - uses: actions/checkout@v5 # The version comes from "packageManager" in package.json. - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v5 with: node-version: 24 cache: pnpm - run: pnpm install --frozen-lockfile - name: A signing secret for this run run: echo "BETTER_AUTH_SECRET=$(openssl rand -base64 32)" >> "$GITHUB_ENV" - name: Lint, typecheck and build everything run: pnpm turbo run lint typecheck build - name: Unit tests run: pnpm turbo run test - name: Apply migrations run: pnpm --filter api db:migrate - name: API end-to-end tests run: pnpm --filter api test:e2e images: name: Docker images build runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v5 - uses: docker/setup-buildx-action@v3 - name: API image uses: docker/build-push-action@v6 with: context: . target: api push: false cache-from: type=gha,scope=api cache-to: type=gha,scope=api,mode=max - name: Web image uses: docker/build-push-action@v6 with: context: . target: web push: false build-args: VITE_API_URL=https://api.example.com cache-from: type=gha,scope=web cache-to: type=gha,scope=web,mode=max