How to Require Conventional Commit PR Titles
A PR title lint action parses the title against Conventional Commits and fails the status check when it does not match.
Run amannn/action-semantic-pull-request on the pull_request title events. It validates that the title starts with an allowed type (feat, fix, chore, and so on) and reports a failing check otherwise.
Steps
- Trigger on
pull_requestwithopened,edited, andsynchronize. - Run
amannn/action-semantic-pull-requestwithGITHUB_TOKEN. - List the allowed types in the
typesinput.
Workflow
.github/workflows/ci.yml
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: read
jobs:
title:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
chore
docs
refactor
requireScope: falseGotchas
- Make the check required in branch protection or a bad title still merges.
- If you squash-merge, the PR title becomes the commit, so this keeps history clean.