Skip to content

chore(commitlint): add commit-msg hook and workflow validation #58

chore(commitlint): add commit-msg hook and workflow validation

chore(commitlint): add commit-msg hook and workflow validation #58

Workflow file for this run

name: Commit Message Check
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
commit-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Validate commit messages
run: |
set -eo pipefail
commits=$(git log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}")
if [ -z "$commits" ]; then
echo "No commits to validate"
exit 0
fi
for sha in $commits; do
echo "Validating commit $sha"
git log -1 --pretty=format:"%B" "$sha" | npx --yes @commitlint/cli@20.4.3
done