name: PR Checks

on:
    pull_request:
        branches: [main]
        types: [opened, synchronize, reopened]

jobs:
    lint-frontend:
        name: Lint Frontend
        runs-on: ubuntu-latest
        steps:
            - name: Checkout code
              uses: actions/checkout@v4

            - name: Setup Node.js
              uses: actions/setup-node@v4
              with:
                  node-version: "20"
                  cache: "npm"
                  cache-dependency-path: frontend/package-lock.json

            - name: Install frontend dependencies
              working-directory: frontend
              run: npm ci

            - name: Run ESLint on frontend
              working-directory: frontend
              run: npm run lint

    build-docker:
        name: Docker Build Check
        runs-on: ubuntu-latest
        steps:
            - name: Checkout code
              uses: actions/checkout@v4

            - name: Set up Docker Buildx
              uses: docker/setup-buildx-action@v3

            - name: Build Docker image (no push)
              uses: docker/build-push-action@v5
              with:
                  context: .
                  push: false
                  tags: lidify:pr-check
                  cache-from: type=gha
                  cache-to: type=gha,mode=max
