name: Commitlint

on:
  pull_request:
    types: [opened, edited, synchronize, reopened]

jobs:
  commitlint:
    runs-on: ubuntu-latest
    name: Lint commit messages
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 22.x
          cache: yarn
      - name: Install dependencies
        run: yarn install --frozen-lockfile --ignore-scripts
      - name: Lint commits
        run: |
          yarn commitlint \
            --from ${{ github.event.pull_request.base.sha }} \
            --to ${{ github.event.pull_request.head.sha }} \
            --verbose
