name: SCALE Preflight

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

jobs:
  preflight:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install project dependencies when present
        shell: bash
        run: |
          if [ -f package-lock.json ]; then
            npm ci
          elif [ -f package.json ]; then
            npm install
          fi

      - name: Run SCALE preflight
        run: npx @hongmaple0820/scale-engine@latest preflight --service all --preflight-profile ci
