From ee1118e8f8bbfc574950b46ff5c9112f488c0ea0 Mon Sep 17 00:00:00 2001 From: Ezra Brooks Date: Wed, 4 Sep 2024 20:09:38 -0600 Subject: [PATCH] Add commit message checker job This commit is deliberately bad, to fail CI! --- .github/workflows/check-commit-messages.yml | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/check-commit-messages.yml diff --git a/.github/workflows/check-commit-messages.yml b/.github/workflows/check-commit-messages.yml new file mode 100644 index 0000000..9658c39 --- /dev/null +++ b/.github/workflows/check-commit-messages.yml @@ -0,0 +1,32 @@ +name: Commit message standards checks + +on: + pull_request: + +jobs: + check_issue_references: + runs-on: ubuntu-24.04 + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + lfs: true + submodules: recursive + # Don't do a shallow clone since we need to poke around in the Git history + fetch-depth: 0 + + - name: Check that every commit name includes an issue reference like "#1" + run: | + IFS=$'\n' + + for f in $(git log --oneline ${{github.base_ref}}..${{github.head_ref}}) + do + if [[ $f =~ ^.*#[0-9]+.*$ ]]; + then + continue + else + echo "Found commit with no issue number: $f" + exit 1 + fi + done + shell: /usr/bin/bash -eo pipefail {0}