-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (32 loc) · 993 Bytes
/
commit-lint.yml
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
name: Commit Lint
on:
pull_request:
types: [opened, synchronize, edited]
push:
branches:
- master
- main
- develop
- feature/**
- release/**
jobs:
lint-commits:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint commit messages
run: |
COMMITS=$(git log --pretty=format:"%s" HEAD^..HEAD 2>/dev/null || git log --pretty=format:"%s" HEAD)
REGEX="^\[(Add|Fix|Update|Remove|Refactor|Docs|Test|Improve)\] .{10,}$"
echo "$COMMITS" | while read -r COMMIT; do
if [[ ! $COMMIT =~ $REGEX ]]; then
echo "Invalid commit message: $COMMIT"
echo "Commit messages must match: '[TYPE] Description' (e.g., '[Add] New feature')."
exit 1
fi
done
- name: Commit messages are valid
run: echo "All commit messages are valid!"