Skip to content

Commit

Permalink
ci: Add Conventional Commits linter for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMob committed Jun 6, 2024
1 parent a281e21 commit 99fe8e9
Show file tree
Hide file tree
Showing 4 changed files with 849 additions and 8 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/commit-linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: commit-linter

on:
pull_request:
push:
branches: [main]

jobs:
commit-lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 20
case: 'pnpm'

- uses: pnpm/action-setup@v3
with:
version: 8

- name: Install commitlint
run: |
pnpm install --frozen-lockfile
- name: Print versions
run: |
git --version
node --version
pnpm --version
pnpm exec commitlint --version
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: pnpm exec commitlint --last --verbose

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: pnpm exec commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
6 changes: 6 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [2, 'always', 'sentence-case'] // override default
}
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"devDependencies": {
"@antora/cli": "^3.1.7",
"@antora/site-generator-default": "^3.1.7",
"http-server": "^14.1.0"
"http-server": "^14.1.0",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2"
}
}
Loading

0 comments on commit 99fe8e9

Please sign in to comment.