name: CI

on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]

jobs:
  server-build:
    runs-on: ubuntu-latest
    name: Server build and type-check (container)
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Server: Type-check and Build (inside node:20)
        run: |
          docker run --rm -v "$PWD":/work -w /work node:20 bash -lc '
            cd server && npm ci --no-audit --no-fund && npm run type-check && npm run build'

  client-build:
    runs-on: ubuntu-latest
    name: Client type-check and build (container)
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Client: Type-check and Build (inside node:20)
        run: |
          docker run --rm -v "$PWD":/work -w /work node:20 bash -lc '
            cd client && npm ci --no-audit --no-fund && npm run type-check && npm run build'
