-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (55 loc) · 2.42 KB
/
Copy pathcommitlint.yml
File metadata and controls
62 lines (55 loc) · 2.42 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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:
- develop
- main
types: [opened, edited, synchronize, reopened]
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
# A main-base PR is a develop -> main release cut: every commit in main..develop
# was already linted at its own PR, while that commit was still mutable and its
# author could still fix it. Re-linting the whole inherited range at cut time adds
# no information and cannot be satisfied (the commits are now immutable, pinned by
# gitlinks and rev-pinned deps). Lint only what THIS PR introduces: its own commit(s).
- name: Lint PR commits (release cut — this PR's own commits only)
if: github.base_ref == 'main'
uses: wagoid/commitlint-github-action@v6
with:
configFile: commitlint.config.mjs
commitDepth: 1
- name: Lint PR commits (feature branch — full PR range)
if: github.base_ref != 'main'
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 }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
# Install both @commitlint/cli AND the extended shareable config so the
# `extends: ['@commitlint/config-conventional']` in commitlint.config.mjs resolves.
# GitHub's squash merge lands "$PR_TITLE (#$PR_NUMBER)" as the commit subject —
# lint that exact string, not the title alone, or a title within the length
# limit can still produce an over-limit commit subject once merged.
printf '%s (#%s)\n' "$PR_TITLE" "$PR_NUMBER" | npx --yes -p @commitlint/cli -p @commitlint/config-conventional \
commitlint --config commitlint.config.mjs