How to Require a Conventional Commit PR Title Check
A pull request title lint validates the title against Conventional Commits and reports a status the branch can require.
Because a squash merge uses the PR title as the commit subject, a title check keeps the history and changelog consistent. Run it on the pull request and make it a required status check.
Steps
- Add a workflow that lints the PR title on
pull_request. - Report a check the branch protection rule requires.
- Enable "Require status checks" and list the title check.
Workflow
.github/workflows/pr-title.yml
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
pull-requests: read
jobs:
pr-title:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Gotchas
- A PR title check runs on
pull_request, not on the merge group; do not require it on the queue or it will hang as "Expected". - Editing the title re-runs the check because of the
editedtype.
Related guides
How to Auto-Merge a Pull Request With the gh CLIEnable auto-merge on a pull request with gh pr merge --auto so GitHub merges it, or adds it to the merge queu…
How to Configure Required Status Checks With the Merge QueueSelect which status checks the GitHub merge queue must pass, and make sure every required check runs on the m…
How to Fix a Merge Queue Stuck on an Expected CheckResolve a merge queue entry that sits pending forever because a required check is listed as expected but neve…