name: PR title

on:
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize
      - reopened

permissions:
  pull-requests: read

jobs:
  # Enforce Conventional Commits in the PR title so the squash-merge commit
  # message produces clean changelog entries for release-plz.
  conventional-commits:
    name: Conventional Commits
    runs-on: ubuntu-latest
    steps:
      - uses: amannn/action-semantic-pull-request@v6
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          types: |
            feat
            fix
            chore
            docs
            refactor
            perf
            test
            build
            ci
            revert
          requireScope: false
          subjectPattern: ^[A-Za-z].+[^.]$
          subjectPatternError: |
            The subject "{subject}" must start with a letter and not end with a period.
