# .github/workflows/ci.yml
name: SiteHive CI

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

jobs:
  build-and-check:
    name: Build, Lint, and Audit
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version-file: ".nvmrc"
          cache: "npm"

      - name: Install dependencies
        run: npm ci

      - name: TypeScript build
        run: npm run build
        env:
          # Provide dummy values so build doesn’t fail on missing env
          NEXT_PUBLIC_FIREBASE_PROJECT_ID: ci-build
          NEXT_PUBLIC_FIREBASE_API_KEY: ci-build
          NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ci-build.firebaseapp.com
          NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ci-build.appspot.com
          NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: "000000000"
          NEXT_PUBLIC_FIREBASE_APP_ID: "1:000000000:web:000000"
          AUTH_SECRET: ci-auth-secret-placeholder-32-chars

      - name: Lint
        run: npm run lint

      - name: Security audit
        run: npm audit --audit-level=high

      - name: Tests (placeholder for future test suite)
        run: echo "No automated tests yet — add them here"
