name: Changeset

on:
  pull_request:
    types: [opened, synchronize, labeled, unlabeled]

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

jobs:
  changeset:
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-changeset') && github.event.pull_request.merged == false }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Setup node
        uses: actions/setup-node@v2
        with:
          node-version: 16
      - name: Check if changeset is added
        run: |
          npx @changesets/cli@2.12.0 status --since=origin/${GITHUB_BASE_REF}
