name: Run UI Component Build

# * Always run on "main"
# * Run on PRs that have changes in the "openhands-ui" folder or this workflow
on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - 'openhands-ui/**'
      -  '.github/workflows/ui-build.yml'

# If triggered by a PR, it will be in the same group. However, each commit on main will be in its own unique group
concurrency:
  group: ${{ github.workflow }}-${{ (github.head_ref && github.ref) || github.run_id }}
  cancel-in-progress: true

jobs:
  ui-build:
    name: Build openhands-ui
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
        with:
          bun-version-file: "openhands-ui/.bun-version"
      - name: Install dependencies
        working-directory: ./openhands-ui
        run: bun install --frozen-lockfile
      - name: Build package
        working-directory:  ./openhands-ui
        run: bun run build
