Skip to content

Commit 2530897

Browse files
committed
ci: add commitlint
1 parent 8fbb2b6 commit 2530897

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

.commitlintrc

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
]
19+
],
20+
"scope-empty": [
21+
0
22+
],
23+
"body-leading-blank": [
24+
1,
25+
"always"
26+
],
27+
"body-max-line-length": [
28+
2,
29+
"always",
30+
100
31+
],
32+
"footer-leading-blank": [
33+
1,
34+
"always"
35+
],
36+
"footer-max-line-length": [
37+
2,
38+
"always",
39+
100
40+
],
41+
"header-max-length": [
42+
2,
43+
"always",
44+
100
45+
],
46+
"subject-case": [
47+
2,
48+
"never",
49+
[
50+
"sentence-case",
51+
"start-case",
52+
"pascal-case"
53+
]
54+
],
55+
"subject-empty": [
56+
2,
57+
"never"
58+
],
59+
"subject-full-stop": [
60+
2,
61+
"never",
62+
"."
63+
],
64+
"type-case": [
65+
2,
66+
"always",
67+
"lower-case"
68+
],
69+
"type-empty": [
70+
2,
71+
"never"
72+
],
73+
"type-enum": [
74+
2,
75+
"always",
76+
[
77+
"build",
78+
"chore",
79+
"ci",
80+
"docs",
81+
"feat",
82+
"fix",
83+
"perf",
84+
"refactor",
85+
"revert",
86+
"cs",
87+
"test"
88+
]
89+
]
90+
}
91+
}

.github/workflows/commitlint.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: commitlint
2+
3+
on: [push, 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)