-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chaerishme' of https://github.com/chaerishme/python-rac…
…ingcar into chaerishme
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Check Commit Message Convention | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
check-commit-message: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code with full history | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # 전체 Git 히스토리를 가져옴 | ||
|
||
- name: Get base branch | ||
run: echo "BASE_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV | ||
|
||
- name: Get all new commit messages in PR | ||
run: | | ||
commit_messages=$(git log --format=%s origin/$BASE_BRANCH..HEAD) | ||
echo "Commit Messages in PR:" | ||
echo "$commit_messages" | ||
echo "COMMIT_MESSAGES<<EOF" >> $GITHUB_ENV | ||
echo "$commit_messages" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Validate commit messages | ||
run: | | ||
invalid_commits=0 | ||
echo "🔍 Checking commit message convention..." | ||
while IFS= read -r commit_message; do | ||
# "Merge"로 시작하는 메시지는 검사에서 제외 | ||
if [[ "$commit_message" =~ ^Merge ]]; then | ||
echo "⚡ Skipping merge commit: $commit_message" | ||
continue | ||
fi | ||
# Commit message validation | ||
if [[ ! "$commit_message" =~ ^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?!?:\ .+ ]]; then | ||
echo "❌ Invalid commit message: $commit_message" | ||
invalid_commits=$((invalid_commits + 1)) | ||
else | ||
echo "✅ Valid commit message: $commit_message" | ||
fi | ||
done <<< "$COMMIT_MESSAGES" | ||
if [[ $invalid_commits -gt 0 ]]; then | ||
echo "🚨 Some commit messages do not follow the convention!" | ||
echo "Example: 'feat: add login API'" | ||
exit 1 | ||
fi | ||
echo "🎉 All commit messages follow the convention!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters