pr-title-conventional
Included in config: 🔒 strict
A repository using this rule enforces that pull request titles follow the Conventional Commits format. Doing so helps to ensure that the purpose of a pull request is clear and consistent for humans and machines.
Specifically, keeping to the conventional commit format helps:
- Humans: it becomes easier to categorize and understand pull request purposes quickly
- Machines: automated tooling can parse those titles into semver-based releases
If a repository has this rule enabled, it’s likely aiming for either or both of those benefits.
Allowed Titles
Section titled “Allowed Titles”This rule asks that titles be in either format:
type: bodytype(scope): bodytype: the conventional commit type, such asdocsorfixscope: an optional single sub-area, commonly a package name if a monorepobody: a lower-case description
Example acceptable titles include:
docs: mention 'rick' feature in README.mdfeat: add optional new 'roll' option to APIfix(parser): don't throw error on consecutive semicolonsOptions
Section titled “Options”This rule accepts the following rule options to restrict which titles are allowed:
types: an array of conventional commit types to allow instead of the default known types- Each type may contain ASCII letters, digits, and
_characters
- Each type may contain ASCII letters, digits, and
scopes: an array of single scopes to allow; titles may still omit a scope- Each scope may contain ASCII letters, digits, spaces, and
_$@.-*/characters
- Each scope may contain ASCII letters, digits, spaces, and
For example, this configuration only allows docs, feat, and fix types, with scopes that are either omitted or are cli or parser:
jobs: octoguide: runs-on: ubuntu-latest steps: - uses: OctoGuide/bot@0.33.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} rules: | { "pr-title-conventional": { "scopes": [ "cli", "parser" ], "types": [ "docs", "feat", "fix" ] } }Subject Options
Section titled “Subject Options”These options restrict the subject portion of a title, after its type and optional scope:
subject-case:"lower"to ask that the subject not start with an upper-case lettersubject-trailing-punctuation:falseto ask that the subject not end with!,,,.,:,;, or?subject-pattern: a regular expression the entire subject must matchsubject-pattern-error: a sentence describingsubject-patternto report in place of the pattern itself
For example, this configuration asks for lower-case subjects without trailing punctuation, optionally prefixed with a bracketed list of rule names:
jobs: octoguide: runs-on: ubuntu-latest steps: - uses: OctoGuide/bot@0.33.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} rules: | { "pr-title-conventional": { "subject-case": "lower", "subject-pattern": "^(\\[[a-z\\-]+(, [a-z\\-]+)*\\] )?[a-z].+$", "subject-pattern-error": "PRs for rules should begin with \"[rule-name] \".", "subject-trailing-punctuation": false } }Examples
Section titled “Examples”Pull request with a non-semantic title:
How to Enable
Section titled “How to Enable”Each snippet in this section shows changes to the full .github/workflows/octoguide.yml workflow from Get Started.
This rule is included in the strict config, which isn't enabled by default. To add it to the rules your workflow already runs, enable it in rules:
jobs: octoguide: runs-on: ubuntu-latest steps: - uses: OctoGuide/bot@0.33.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} rules: | { "pr-title-conventional": true }Alternatively, switch to the strict config to enable this rule along with every other strict rule:
jobs: octoguide: runs-on: ubuntu-latest steps: - uses: OctoGuide/bot@0.33.2 with: config: strict github-token: ${{ secrets.GITHUB_TOKEN }}To use this rule on its own, enable it in rules with the none config:
jobs: octoguide: runs-on: ubuntu-latest steps: - uses: OctoGuide/bot@0.33.2 with: config: none github-token: ${{ secrets.GITHUB_TOKEN }} rules: | { "pr-title-conventional": true }
[ pr-title-conventional ]
The PR title is missing a conventional commit type, such as “docs: “ or “feat: “. This repository asks that pull request titles start with a type in the Conventional Commits format. Doing so helps make the purpose of each pull request clear for humans and machines. To resolve this report, add a conventional commit type in front of the title, like “feat: Update README.md”.