name: Check CULTSCALE OS (Worker)

on:
  pull_request:
    paths:
      - 'portal/**'
      - '.github/workflows/check-cultscale-os.yml'
  workflow_dispatch:

jobs:
  check:
    runs-on: ubuntu-latest
    permissions:
      contents: read

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

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'npm'
          cache-dependency-path: portal/package-lock.json

      - name: Install portal dependencies
        working-directory: portal
        run: npm ci

      - name: Install Wrangler
        run: npm install -g wrangler@latest

      - name: Validate Worker bundle (dry-run)
        working-directory: portal
        run: wrangler deploy --dry-run --config wrangler.toml
