Skip to content

Commit

Permalink
Check commit message length in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Mar 15, 2024
1 parent a63b043 commit 295a789
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/check-commit-msg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
- name: Fetch branch data from origin
run: git fetch origin
- 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

0 comments on commit 295a789

Please sign in to comment.