name: Frontend CI

on:
  push:
    branches:
      - master
      - main
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 20

    steps:
      # `package.json` uses `@authcore/commons`: `file:../AuthCoreJS` — need sibling checkout like local monorepo.
      - name: Checkout huike-front
        uses: actions/checkout@v4
        with:
          path: huike-front

      - name: Checkout AuthCoreJS
        uses: actions/checkout@v4
        with:
          repository: alchemy-studio/AuthCoreJS
          path: AuthCoreJS

      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 9

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: pnpm
          cache-dependency-path: huike-front/pnpm-lock.yaml

      - name: Install dependencies
        working-directory: huike-front
        run: pnpm install --frozen-lockfile

      - name: Build
        working-directory: huike-front
        run: pnpm run build
