chore(commitlint): add commit-msg hook and workflow validation #58
Workflow file for this run
This file contains hidden or 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: 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 |