name: 'CI: Size Data'

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

concurrency:
  group: size-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  changes:
    if: github.repository == 'Comfy-Org/ComfyUI_frontend'
    runs-on: ubuntu-latest
    permissions:
      contents: read
    outputs:
      should-run: ${{ steps.changes.outputs.should-run }}
    steps:
      - uses: actions/checkout@v6
      - id: changes
        uses: ./.github/actions/changes-filter

  collect:
    needs: changes
    if: ${{ needs.changes.outputs.should-run == 'true' }}
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6

      - name: Setup frontend
        uses: ./.github/actions/setup-frontend

      - name: Build project
        run: pnpm build

      - name: Collect size data
        run: node scripts/size-collect.js

      - name: Upload size data
        uses: actions/upload-artifact@v6
        with:
          name: size-data
          path: temp/size
