This reusable GitHub Actions workflow validates that pull request titles follow the Conventional Commits specification. Conventional Commits provide a standardized format for commit messages, making it easier to generate changelogs, automate versioning, and understand the purpose of changes at a glance. By enforcing this standard, your repository maintains a clean and meaningful history that benefits both developers and automated tools.
Conventional Commits follow this structured format:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
β¨ feat: A new feature that adds functionality to your codebaseπ fix: A bug fix that resolves an issue or problemπ docs: Documentation changes or improvementsπ style: Changes that don't affect code meaning (formatting, white-space, etc.)β»οΈ refactor: Code changes that neither fix bugs nor add features but improve structureπ§ͺ test: Adding or correcting tests to ensure code qualityπ§ chore: Changes to the build process, dependencies, or auxiliary toolsβ‘ perf: Performance improvements that make your code fasterπ security: Fixing security vulnerabilities or enhancing security
- π Automated Changelog Generation: Works seamlessly with tools like release-please to create detailed, organized changelogs without manual effort
- π’ Semantic Versioning Automation: Helps determine version bumps based on commit types (major, minor, patch) following SemVer principles
- π Improved Repository History: Makes your project history more readable, structured, and navigable for all team members
- π₯ Better Collaboration: Provides clear context for code reviewers, making the review process more efficient
- π Consistent Communication: Establishes a common language for discussing changes across your team
- π€ CI/CD Integration: Enables automated workflows based on commit types for more sophisticated pipelines
| Name | Description | Required |
|---|---|---|
GITHUB_TOKEN |
GitHub token for authentication and PR interactions | Yes |
The workflow requires pull-requests: read permission to access PR information and validate titles effectively.
name: Lint PR Title
on:
pull_request_target:
types:
- opened
- edited
- reopened
jobs:
lint-pr-title:
permissions:
pull-requests: read
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/conventional-commits.yml@conventional-commits-v1.0.1- π The workflow runs automatically when PRs are opened, edited, or reopened to ensure continuous validation
- β It validates the PR title against the Conventional Commits specification with comprehensive checks
- π¬ If validation fails, the workflow will comment on the PR with detailed guidance on how to fix the title
- π This workflow is particularly useful when combined with the release-please workflow for a fully automated release process
- π Helps maintain a high-quality repository that's ready for automated versioning and changelog generation
- If PR titles are consistently failing validation, consider providing team training on Conventional Commits
- For complex projects, you may want to define custom scopes that align with your project's architecture
- Remember that only the PR title needs to follow the convention, not every commit message (though that's also beneficial)