From 295a789c429ee269a6a18142f7f6f43d0024d767 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Fri, 15 Mar 2024 15:22:38 +0100 Subject: [PATCH] Check commit message length in CI --- .github/workflows/check-commit-msg.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/check-commit-msg.yml diff --git a/.github/workflows/check-commit-msg.yml b/.github/workflows/check-commit-msg.yml new file mode 100644 index 0000000000..e39008068f --- /dev/null +++ b/.github/workflows/check-commit-msg.yml @@ -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