name: Bundle Size

on: [pull_request]

jobs:
  size:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Install dependencies
        run: yarn install --frozen-lockfile

      # Posts a PR comment showing the gzip size diff vs the base branch.
      # Does not require size-limit to be installed on the base branch —
      # measures the built artifact sizes directly.
      - uses: preactjs/compressed-size-action@v2
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'
          pattern: 'dist/{index.es.js,index.js}'
          build-script: 'build'
