Skip to content

[.github] Update check commit workflow (#44) #72

[.github] Update check commit workflow (#44)

[.github] Update check commit workflow (#44) #72

Workflow file for this run

name: Check Commit
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
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"