# Conventional commits (CONTRIBUTING.md): release-please reads them to choose the next version and write the
# CHANGELOG. A pull request's title is checked because a squash merge makes it the commit on main.
name: commitlint

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

permissions: {}

jobs:
  commitlint:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
        with:
          node-version: 24
      - run: npm install --no-save --no-package-lock --no-audit --no-fund @commitlint/cli@21.2.4 @commitlint/config-conventional@21.2.4
      - name: Pull request title
        env:
          TITLE: ${{ github.event.pull_request.title }}
        run: npx --no-install commitlint --verbose <<< "$TITLE"
      - name: Commits
        env:
          BASE: ${{ github.event.pull_request.base.sha }}
          HEAD: ${{ github.event.pull_request.head.sha }}
        run: npx --no-install commitlint --verbose --from "$BASE" --to "$HEAD"
