[.github] Add double quote in check_commit workflow (#45) #76
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
name: Check Commit | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
check-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get commit message | |
if: github.event_name == 'push' | |
run: | | |
echo "${{ github.event.head_commit.message }}" > commit_msg.txt | |
- name: Get commit message | |
if: github.event_name == 'pull_request' | |
run: | | |
git log origin/${{ github.base_ref }}..HEAD --format=%b > commit_msg.txt | |
- name: Get commit body | |
run: | | |
tail -n +2 commit_msg.txt > commit_body.txt | |
- name: Check signed-off | |
run: | | |
count=$(cat commit_body.txt | grep 'Signed-off-by:' | wc -l) | |
if [[ ! "$count" -ge "1" ]]; then | |
exit 1 | |
fi | |
echo "Signed-off-by is OK" | |
- name: Check body words | |
if: always() | |
run: | | |
count=$(cat commit_body.txt | sed '/Signed-off-by:/d' | wc -w) | |
echo "Commit body word check: $count words" | |
if [[ "$count" -lt "5" ]]; then | |
exit 1 | |
fi | |
echo "Body words count is OK" |