1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Enforce Conventional Commits on every PR to the default branch (and the PR title).
# Reads commitlint.config.mjs at the repo root (extends @commitlint/config-conventional).
# No local install needed โ the action bundles commitlint. See CLAUDE.md ยง3.2.
name: Commitlint
on:
pull_request:
branches:
- main
types:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
commitlint:
name: Lint commit messages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Lint PR commits
uses: wagoid/commitlint-github-action@v6
with:
configFile: commitlint.config.mjs
- name: Lint PR title
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
set -euo pipefail
# Install both @commitlint/cli AND the extended shareable config so the
# `extends: ['@commitlint/config-conventional']` in commitlint.config.mjs resolves.
echo "$PR_TITLE" | npx --yes -p @commitlint/cli -p @commitlint/config-conventional \
commitlint --config commitlint.config.mjs