File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 - master
1010
1111jobs :
12+ commitlint :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 0
19+
20+ - name : Validate commit message
21+ run : |
22+ # Get commit message(s) to validate
23+ if [ "${{ github.event_name }}" = "pull_request" ]; then
24+ COMMITS=$(git log --format=%s origin/${{ github.base_ref }}..HEAD)
25+ else
26+ COMMITS=$(git log -1 --format=%s)
27+ fi
28+
29+ # Conventional commit pattern: type(scope): emoji description
30+ # type is required, scope is optional, emoji after colon is optional
31+ PATTERN='^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert)(\([a-zA-Z0-9_-]+\))?: .+'
32+
33+ echo "Validating commit messages..."
34+ FAILED=0
35+ while IFS= read -r MSG; do
36+ if [ -n "$MSG" ]; then
37+ if echo "$MSG" | grep -qE "$PATTERN"; then
38+ echo "✅ $MSG"
39+ else
40+ echo "❌ $MSG"
41+ echo " Expected format: type(scope): description"
42+ echo " Example: feat(auth): ✨ add login feature"
43+ FAILED=1
44+ fi
45+ fi
46+ done <<< "$COMMITS"
47+
48+ if [ $FAILED -eq 1 ]; then
49+ echo ""
50+ echo "Commit message validation failed!"
51+ echo "Please follow Conventional Commits: https://www.conventionalcommits.org/"
52+ exit 1
53+ fi
54+
1255 ci :
1356 runs-on : ubuntu-latest
57+ needs : commitlint
1458
1559 steps :
1660 - name : Checkout code
You can’t perform that action at this time.
0 commit comments