name: Size Limit

on:
  pull_request:
    branches:
      - master
      - main
    paths:
      - 'packages/core/src/**'
      - 'packages/core/package.json'
      - '.size-limit.json'

permissions:
  contents: read
  pull-requests: write
  issues: write

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

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

      - name: Install dependencies
        run: npm ci

      - name: Build core package
        run: |
          cd packages/core
          npm run build:npm

      - name: Check bundle size
        uses: andresz1/size-limit-action@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          skip_step: install
