name: Changeset Status

on: [pull_request]

permissions:
  contents: read

jobs:
  # Enforce that all PRs that change packages need changesets. Changes
  # without changesets result in this job failing.
  changeset:
    runs-on: ubuntu-latest
    # Skip if author is lit-robot which means it's a release PR that doesn't
    # need this check.
    if: ${{ github.event.pull_request.user.login != 'lit-robot' }}
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: actions/setup-node@v3
        with:
          node-version: 24.5
          cache: 'npm'
          cache-dependency-path: package-lock.json

      - name: Checkout and NPM install
        run: |
          git checkout main
          git checkout ${{ github.sha }}
          npm ci

      - name: Changeset status
        run: npm run changeset status -- --since=main
