name: commitlint
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- "*"
jobs:
run-commitlint-on-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 22.16.0
- name: Install dependencies
run: npm install -g @commitlint/{cli,config-conventional}
- name: Validate commits
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
FROM="${{ github.event.pull_request.base.sha }}"
TO="${{ github.event.pull_request.head.sha }}"
else
FROM="${{ github.event.before }}"
TO="${{ github.sha }}"
if [ -z "$FROM" ] || [ "$FROM" = "0000000000000000000000000000000000000000" ]; then
FROM="HEAD~1"
fi
fi
npx commitlint --from "$FROM" --to "$TO" --verbose