name: 'Commitlint'

on:
  push:
    branches:
      - main
  pull_request:

permissions:
  contents: read # to fetch code (actions/checkout)
  actions: read

jobs:
  commitlint:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v6
        with:
          node-version: 24
      - uses: nrwl/nx-set-shas@v5
      - name: Monorepo install
        uses: ./.github/actions/yarn-nm-install
      - name: Validate PR commits with commitlint
        if: github.event_name == 'pull_request'
        run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
