-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (38 loc) · 1.17 KB
/
commitlint.yml
File metadata and controls
44 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Commitlint
on:
pull_request:
types: [opened, synchronize, reopened, edited]
push:
branches:
- main
- master
jobs:
commitlint:
name: Validate Commit Messages
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Validate current commit (push)
if: github.event_name == 'push'
run: |
# Check if this is the first commit
if git rev-parse HEAD~1 >/dev/null 2>&1; then
# Not the first commit, validate from previous commit
npx commitlint --from HEAD~1 --to HEAD --verbose
else
# First commit, validate only HEAD
npx commitlint --from HEAD --to HEAD --verbose
fi
- name: Validate PR commits
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose