Code Issues Pull Requests Actions Packages Projects Releases 15 Wiki Activity Security Code Quality

ci: Add Conventional Commits Check workflow to validate PR titles and descriptions along with commit messages

This commit is contained in:
tienbh committed 2026-11-26 18:07:32 +07:00 Verified
1 parent a1146a4d07
commit b47068f081
1 file changed
@@ -0,0 +1,43 @@
name: Conventional Commits Check
on:
pull_request:
types: [opened, edited, synchronize, reopened]
env:
NODE_VERSION: '24'
jobs:
lint-commits-and-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install commitlint
run: npm install --no-save @commitlint/cli @commitlint/config-conventional
- name: Validate PR Title & Description (<= 500 chars)
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
if [ -z "$PR_BODY" ]; then
printf "%s\n" "$PR_TITLE" | npx commitlint
else
printf "%s\n\n%s\n" "$PR_TITLE" "$PR_BODY" | npx commitlint
fi
- name: Validate All Commits in PR
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
npx commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose