Skip to content

Commit 1920bf7

Browse files
authored
ci: add husky and commitlint for checking git commit messages (#8)
1 parent 91f85b3 commit 1920bf7

File tree

5 files changed

+857
-1
lines changed

5 files changed

+857
-1
lines changed

.github/workflows/commitlint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Run commitlint on git commit messages
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
commitlint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout the repository
10+
uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
19+
- name: Print versions
20+
run: |
21+
git --version
22+
node --version
23+
npm --version
24+
npx commitlint --version
25+
26+
- name: Install commitlint
27+
run: |
28+
npm install conventional-changelog-conventionalcommits
29+
npm install commitlint@latest
30+
31+
- name: Validate current commit (last commit) with commitlint
32+
if: github.event_name == 'push'
33+
run: npx commitlint --last --verbose
34+
35+
- name: Validate PR commits with commitlint
36+
if: github.event_name == 'pull_request'
37+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

0 commit comments

Comments
 (0)