Skip to content

Commit f0a0e4a

Browse files
committed
chore: add hooks for commit messages
1 parent 1bd23d4 commit f0a0e4a

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

.git_hooks/commit-msg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
npx commitlint --edit $1
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lint Commit Messages
2+
on: [pull_request]
3+
4+
permissions:
5+
pull-requests: write
6+
jobs:
7+
commitlint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- uses: wagoid/commitlint-github-action@456526eec71276a59e74aafdfe06a9632ac2eee1
14+
id: commitlint
15+
- if: ${{ failure() && steps.commitlint.outcome == 'failure' }}
16+
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd
17+
with:
18+
header: Commitlint
19+
recreate: true
20+
message: |
21+
## Wrong commit message format detected
22+
We use [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) in our project.
23+
24+
> **Warning**
25+
> Probably you forgot to activate local git hooks.
26+
27+
Run the next command in the project root to activate local hooks:
28+
```sh
29+
sh ./scripts/install_hooks.sh
30+
```
31+
32+
More info you can find in [job logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
33+
- if: ${{ success() }}
34+
uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd
35+
with:
36+
header: Commitlint
37+
hide: true
38+
hide_classify: "OUTDATED"

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'] };

scripts/install_hooks.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
# Make .git_hooks folder as hooks source for git
4+
git config core.hooksPath .git_hooks/
5+
6+
# install commitlint and @commitlint/config-conventional globally
7+
npm install -g commitlint @commitlint/config-conventional

0 commit comments

Comments
 (0)