Skip to content

Commit 6fb6c11

Browse files
authored
chore: add commit-lint (#3325)
1 parent d30bb6e commit 6fb6c11

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/lint-commit.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint Commits
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read # to fetch code (actions/checkout)
8+
9+
jobs:
10+
lint-pr-first-commit:
11+
name: Commit Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version: 22.x
20+
- run: npm install
21+
- name: Lint first PR commit message
22+
run: |
23+
FIRST=$(git rev-list --reverse ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | head -1)
24+
echo "Base: ${{ github.event.pull_request.base.sha }}"
25+
echo "Head: ${{ github.event.pull_request.head.sha }}"
26+
echo "First PR commit: $FIRST"
27+
git log -1 --format=%B "$FIRST" | npx commitlint --verbose

commitlint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
extends: ['@commitlint/config-conventional']
3+
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
3838
},
3939
"devDependencies": {
40+
"@commitlint/cli": "^21.0.2",
41+
"@commitlint/config-conventional": "^21.0.2",
4042
"bindings": "^1.5.0",
4143
"cross-env": "^10.1.0",
4244
"eslint": "^9.39.1",

0 commit comments

Comments
 (0)