name: Commitlint

on:
  pull_request:
    branches:
      - main

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

permissions:
  checks: write
  contents: read
  pull-requests: read

jobs:
  commitlint:
    runs-on: ubuntu-22.04
    timeout-minutes: 5
    steps:
      - name: Check out Git repository
        uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
        with:
          # by default this only fetches the latest commit,
          # but more commits are needed to validate a range of commit messages
          fetch-depth: 0

      - name: Validate commit messages
        uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
        with:
          configFile: .commitlintrc.mjs
          helpURL: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
