Conventional Commits
Validate commit messages against the Conventional Commits specification.
-Overviewâ
-This GitHub Action ensures all commit messages in your repository follow the Conventional Commits format. This is essential for:
--
-
- Automated semantic versioning -
- Automatic changelog generation -
- Clear commit history -
- Better team communication -
Conventional Commits Formatâ
-type(scope): description
body
footer
Example:
-feat(auth): add login with Google OAuth
- Implemented Google OAuth provider
- Added login redirect flow
Closes #123
Installationâ
-Add to your workflow:
-name: Validate Commits
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: helpers4/action/conventional-commits@v1
Configurationâ
-Basic Optionsâ
-- uses: helpers4/action/conventional-commits@v1
with:
# Allowed types (comma-separated)
types: 'feat,fix,chore,refactor,docs'
# Require scope in commits
requireScope: false
# Custom error message
errorMessage: 'Commit message must follow Conventional Commits'
Allowed Commit Typesâ
-| Type | Purpose |
|---|---|
feat | A new feature |
fix | A bug fix |
chore | Build, deps, or tooling |
refactor | Code refactoring |
docs | Documentation |
style | Code style (formatting) |
test | Tests |
perf | Performance |
ci | CI/CD configuration |
With Scope Requirementsâ
-- uses: helpers4/action/conventional-commits@v1
with:
types: 'feat,fix,chore'
requireScope: true
Valid:
--
-
feat(api): add endpoint
-fix(button): remove hover state
-
Invalid:
--
-
feat: add endpointâ
-
Examplesâ
-Standard CI/CDâ
-name: PR Validation
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: helpers4/action/conventional-commits@v1
with:
types: 'feat,fix,chore,refactor,docs,style,test,perf'
With Automatic Releaseâ
-- uses: helpers4/action/conventional-commits@v1
- name: Create Release
if: github.event_name == 'push'
run: npm run release
Custom Error Handlingâ
-- uses: helpers4/action/conventional-commits@v1
with:
errorMessage: |
â Your commit doesn't follow our convention!
Format: type(scope): description
Types: feat, fix, chore, refactor, docs
Example: feat(auth): add OAuth login
Versioningâ
--
-
helpers4/action/conventional-commits@latest- Latest version
-helpers4/action/conventional-commits@v1- Current major version
-helpers4/action/conventional-commits@v1.2.3- Specific version
-
GitHub Marketplaceâ
-Find more helpers4 actions on GitHub Marketplace
-Troubleshootingâ
-Action Returns Falseâ
-Ensure format is correct:
--
-
- â
add login feature
- - â
feat: add login feature
-
Scope Not Recognizedâ
-Provide scope when required:
--
-
- â
feat: add api
- - â
feat(api): add endpoint
-
-