Skip to content

Commit a1d8cc2

Browse files
committedFeb 9, 2025··
ci: add commitlint
1 parent 6d416ff commit a1d8cc2

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed
 

‎.commitlintrc

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"defaultIgnores": true,
3+
"extends": "@commitlint/config-conventional",
4+
"rules": {
5+
"scope-enum": [
6+
2,
7+
"always",
8+
[
9+
"app",
10+
"config",
11+
"database",
12+
"routes",
13+
"resources",
14+
"laravel",
15+
"api-p",
16+
"js",
17+
"blade",
18+
"deps",
19+
"larastan",
20+
]
21+
],
22+
"scope-empty": [
23+
0
24+
],
25+
"body-leading-blank": [
26+
1,
27+
"always"
28+
],
29+
"body-max-line-length": [
30+
2,
31+
"always",
32+
100
33+
],
34+
"footer-leading-blank": [
35+
1,
36+
"always"
37+
],
38+
"footer-max-line-length": [
39+
2,
40+
"always",
41+
100
42+
],
43+
"header-max-length": [
44+
2,
45+
"always",
46+
100
47+
],
48+
"subject-case": [
49+
2,
50+
"never",
51+
[
52+
"sentence-case",
53+
"start-case",
54+
"pascal-case"
55+
]
56+
],
57+
"subject-empty": [
58+
2,
59+
"never"
60+
],
61+
"subject-full-stop": [
62+
2,
63+
"never",
64+
"."
65+
],
66+
"type-case": [
67+
2,
68+
"always",
69+
"lower-case"
70+
],
71+
"type-empty": [
72+
2,
73+
"never"
74+
],
75+
"type-enum": [
76+
2,
77+
"always",
78+
[
79+
"build",
80+
"chore",
81+
"ci",
82+
"docs",
83+
"feat",
84+
"fix",
85+
"perf",
86+
"refactor",
87+
"revert",
88+
"cs",
89+
"test"
90+
]
91+
]
92+
}
93+
}

‎.github/workflows/commitlint.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: commitlint
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
commitlint:
7+
if: github.event_name == 'pull_request'
8+
env:
9+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Run commitlint
14+
run: |
15+
commit=$(gh api \
16+
/repos/${{ github.repository }}/pulls/${{github.event.number}}/commits \
17+
| jq -r '.[0].commit.message' \
18+
| head -n 1)
19+
# we can't use npx see https://github.com/conventional-changelog/commitlint/issues/613
20+
echo '{}' > package.json
21+
npm install --no-fund --no-audit @commitlint/config-conventional @commitlint/cli
22+
echo $commit | ./node_modules/.bin/commitlint -g .commitlintrc

0 commit comments

Comments
 (0)
Please sign in to comment.