name: CI

on:
  push:
    branches: [ main, local-main ]
  pull_request:
    branches: [ main, local-main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Run lint (if available)
        run: npm run lint --if-present

      - name: Run tests (if available)
        run: npm test --if-present

      - name: Build
        run: npm run build --if-present

      - name: Upload build artifact
        if: success()
        uses: actions/upload-artifact@v4
        with:
          name: next-build
          path: .next
