Enforce Conventional Commits on pull request titles like a true sheriff, keep your repo law-abiding!
Sheriff is a GitHub Action that patrols your pull requests and ensures titles follow a strict format. Perfect for enforcing Conventional Commits or your own custom rules.
No more wild, lawless PR titles - the Sheriff keeps things tidy.
- Enforces the
type(scope): messageformat - Supports multiple scopes -
type(scope1|scope2): message - Detects breaking changes (
!) and checks if they’re allowed - Fully configurable types & scopes
- Flexible input formats for
typesandscopes(comma, newline, arrays, pipes) - Instantly fails CI if rules are broken
- Works in any PR workflow
Follow these steps and your repo will be safer than a vault in Fort Knox.
-
Star the repo - show the Sheriff some love before he starts working 😁.
-
Create a workflow file
.github/workflows/check-pr-title.yml. -
Copy this template into your file:
name: PR Title Check on: pull_request: types: [opened, edited, synchronize] jobs: sheriff: runs-on: ubuntu-latest steps: - name: Validate PR title uses: teneplaysofficial/sheriff@v3 with: types: [feat, fix, docs, ci, test, chore] scopes: | core api ui docs allow_breaking: true enforce_scopes: true
-
Commit & push - the Sheriff is now on duty. Any outlaw PR title will be gunned down.
| Name | Required | Default | Description |
|---|---|---|---|
types |
No | Loaded from types.json |
List of allowed commit types |
scopes |
No | Loaded from scopes.json |
Same as types but for commit scopes |
allow_breaking |
No | true |
Whether breaking changes (!) are allowed |
enforce_scopes |
No | false |
If true, only scopes from config or input are allowed; else any pass any value |
All of these work for types or scopes:
# Comma-separated
types: feat,fix,docs
# Pipe-separated
types: feat|fix|docs
# Multiline block
scopes: |
core
api
ui
# YAML array
scopes: [core, api, ui]
# JSON array (quoted)
types: '["feat","fix","docs"]'| Name | Description |
|---|---|
valid |
true if title passes validation, else false |
Sheriff-approved examples:
feat(api): add authentication supportfix(core|ui): resolve dark mode toggle bugdocs: update contributing guide
Titles that’ll land you in PR jail:
feature: add new login page- type not allowedfix(auth):- message emptyperformance(core): rename variables- type not in allowed list
- Sheriff loads default types and scopes from JSON files.
- If you give workflow inputs, they override the defaults.
- Inputs are normalized with
parseList, supporting commas, pipes, YAML arrays, JSON arrays, or multiline blocks. - The PR title is checked against the Sheriff’s regex badge.
- PR is marked invalid if:
- Type is not allowed
- Scope is not allowed (only when
enforce_scopesistrue) - Breaking change (
!) is present but disallowed - Message is empty
Released under the Apache-2.0 License.
The Sheriff works free of charge, but tips are appreciated in the form of stars.