~/
Overview

Using Conventional Commits in GitHub Actions

May 27, 2024
1 min read

Maintaining a clear commit history is crucial in software projects. Conventional Commits provide a structured way to format commit messages, which can be enforced using GitHub Actions.

Setting Up the GitHub Action

Create a workflow file at .github/workflows/conventional-commits.yml:

name: Conventional Commits
on:
pull_request:
types: [opened, synchronize, reopened, edited]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
jobs:
conventional-commits:
runs-on: ubuntu-latest
steps:
- uses: ytanikin/PRConventionalCommits@1.1.0
with:
task_types: '["feat","fix","docs","refactor","test","ci","chore","revert","release","merge","hotfix"]'

This action validates pull request titles against the Conventional Commits standard, triggering on pull request events.

Conventional Commit Format

Messages follow this pattern:

<type>[optional scope]: <description>
[optional body]
[optional footer(s)]

Common Types

TypeDescription
featA new feature
fixA bug fix
docsDocumentation changes
refactorCode refactoring
testAdding or updating tests
ciCI/CD changes
choreMaintenance tasks
revertReverting a previous commit
releaseRelease-related changes
mergeMerge commits
hotfixCritical bug fixes

Examples

feat: add user login feature
fix: resolve issue with user logout
docs: update README with setup instructions
ci: add conventional commits workflow
refactor: extract auth logic into service

Benefits

  1. Automated changelogs — Generate changelogs automatically from commit history
  2. Semantic versioning — Automate version bumps based on commit types
  3. Clearer communication — Standardized messages make the history readable for the entire team

Conclusion

By integrating Conventional Commits into your GitHub workflow, you ensure a maintainable and understandable commit history. The automation catches non-conforming titles early, keeping your project’s git log clean and useful.