name: Build Web App

on:
  push:
    paths:
      - ".yalc/**"
      - "web/apps/web/**"
      - "web/packages/**"
      - ".github/workflows/build-web.yaml"
  pull_request:
    paths:
      - ".yalc/**"
      - "web/apps/web/**"
      - "web/packages/**"
      - ".github/workflows/build-web.yaml"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - uses: pnpm/action-setup@v2
        with:
          version: 9
          run_install: false

      - uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "pnpm"
          cache-dependency-path: "web/pnpm-lock.yaml"

      - working-directory: "./web"
        run: pnpm install

      - working-directory: "./web"
        run: pnpm turbo run build --filter=web
        env:
          NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}

      - uses: actions/upload-artifact@v3
        with:
          name: web-build
          path: web/apps/web/dist
