-
Notifications
You must be signed in to change notification settings - Fork 7
58 lines (44 loc) · 1.7 KB
/
Copy pathgit-lint.yml
File metadata and controls
58 lines (44 loc) · 1.7 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Git Lint
on:
pull_request:
branches: [ main, dev, develop ]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate Branch Name
run: |
BRANCH="${{ github.head_ref }}"
echo "🔍 Checking branch name: $BRANCH"
REGEX="^(feature|refactor|fix|chore|build|style|docs|release)/.+$"
if [[ ! "$BRANCH" =~ $REGEX ]]; then
echo "❌ Invalid branch name: '$BRANCH'"
echo "💡 Use: feature/name, fix/bug-name, etc."
exit 1
fi
echo "✅ Branch name is valid."
- name: Validate Commit Messages
run: |
echo "🔍 Checking commit messages in PR..."
COMMITS=$(git log --no-merges --pretty=%B origin/${{ github.base_ref }}..HEAD)
REGEX="^(feat|fix|chore|refactor|test|docs|style|ci|perf|build|revert)(\(.+\))?:\ .+"
CYRILLIC_REGEX='[а-яА-ЯёЁіІїЇєЄ]'
while IFS= read -r MSG; do
if [ -z "$MSG" ]; then continue; fi
echo "💬 Testing: $MSG"
if [[ ! "$MSG" =~ $REGEX ]]; then
echo "❌ Invalid format: '$MSG'"
echo "💡 Use: feat(scope): description"
exit 1
fi
if [[ "$MSG" =~ $CYRILLIC_REGEX ]]; then
echo "❌ Cyrillic detected in: '$MSG'"
echo "💡 Use English only for commit messages."
exit 1
fi
done <<< "$COMMITS"
echo "✅ All commit messages are valid."