name: Next.js Build Check

on:
  pull_request:
    paths:
      - 'js/cf-webapp/**'

jobs:
  build:
    env:
      NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: read

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

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          registry-url: https://npm.pkg.github.com
          scope: '@codeflash-ai'

      - name: Install dependencies
        run: |
          cd js/cf-webapp
          npm install

      - name: Build and package app
        run: |
          cd js/cf-webapp
          npm run build