Check length of commit messages on PR CI #5
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 Messages | |
on: | |
pull_request: | |
jobs: | |
length: | |
name: Check that length of commit messages are <72 characters | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
env | |
- run: | | |
git remote | |
git branch | |
- run: | | |
COMMIT_MESSAGES=$(git log --format=%s origin/$GITHUB_BASE_REF..HEAD) | |
for MESSAGE in $COMMIT_MESSAGES; do | |
LENGTH=$(echo $MESSAGE | wc -c) | |
if [ $LENGTH -gt 72 ]; then | |
echo "Commit message \"$MESSAGE\" is too long ($LENGTH characters). Please keep commit messages under 72 characters." | |
exit 1 | |
fi | |
done |