Skip to content

lint-commits.yml ​

Validate commit messages follow the Conventional Commits specification using commitlint. Supports both pull request and push events with configurable rules.

Inputs ​

InputTypeDescriptionRequiredDefault
COMMITS_SOURCEstringSource of commits to lint (pr for PR, push for push)No"pr"
CONFIG_FILEstringPath to custom commitlint config fileNo""
FAIL_ON_ERRORbooleanWhether to fail the workflow on linting errorsNotrue
ALLOWED_TYPESstringComma-separated list of allowed commit typesNo"feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert"
REQUIRE_SCOPEbooleanWhether to require a scope in commit messagesNofalse
MAX_SUBJECT_LENGTHnumberMaximum length of the commit header line (including type(scope): prefix) — controls commitlint's header-max-length ruleNo100
RUNS_ONstringRunner labels as JSON array (e.g., '["ubuntu-24.04"]' or '["self-hosted", "linux"]')No["ubuntu-24.04"]

Permissions ​

ScopeAccessDescription
contentsreadRead commit history

Notes ​

  • Conventional Commits Format: <type>(<scope>): <subject>
  • Default Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
  • Uses Bun runtime for fast package installation and execution.
  • Uses @commitlint/cli with @commitlint/config-conventional as the base configuration.
  • Automatically generates a commitlint config if no custom config file is provided.
  • Produces a summary table in the GitHub Actions workflow summary showing each commit's status.
  • For PRs, lints all commits between the base and head branches.
  • For push events, lints commits between the previous and current SHA.
  • Custom configuration files (e.g., commitlint.config.js) take precedence over auto-generated config.

Examples ​

The following examples cover basic commit linting, scope enforcement, custom allowed types, external config files, non-blocking mode, and linting push events instead of pull requests.

Simple example ​

Lints all PR commits against the default Conventional Commits ruleset with no extra configuration. The 11 standard types are accepted and no scope is required.

yaml
jobs:
  lint-commits:
    uses: this-is-tobi/github-workflows/.github/workflows/lint-commits.yml@v0
    permissions:
      contents: read

Require scope ​

REQUIRE_SCOPE: true makes the (scope) part of the format mandatory — feat: add feature fails, while feat(auth): add feature passes.

yaml
jobs:
  lint-commits:
    uses: this-is-tobi/github-workflows/.github/workflows/lint-commits.yml@v0
    permissions:
      contents: read
    with:
      REQUIRE_SCOPE: true

Custom allowed types ​

Restricts the accepted types to a minimal set and lowers the commit header length limit to 72 characters — a common Git convention that fits in standard terminal widths.

yaml
jobs:
  lint-commits:
    uses: this-is-tobi/github-workflows/.github/workflows/lint-commits.yml@v0
    permissions:
      contents: read
    with:
      ALLOWED_TYPES: "feat,fix,docs,chore"
      MAX_SUBJECT_LENGTH: 72

Use custom config file ​

Loads the full commitlint configuration from .commitlintrc.js. All inline inputs (ALLOWED_TYPES, REQUIRE_SCOPE, MAX_SUBJECT_LENGTH) are overridden by the config file.

yaml
jobs:
  lint-commits:
    uses: this-is-tobi/github-workflows/.github/workflows/lint-commits.yml@v0
    permissions:
      contents: read
    with:
      CONFIG_FILE: .commitlintrc.js

Non-blocking check ​

Violations appear in the workflow summary table without failing the job. Useful when rolling out Conventional Commits on a repository that already has non-conforming commit history.

yaml
jobs:
  lint-commits:
    uses: this-is-tobi/github-workflows/.github/workflows/lint-commits.yml@v0
    permissions:
      contents: read
    with:
      FAIL_ON_ERROR: false

For push events ​

COMMITS_SOURCE: push switches the commit range from the PR context to the push SHA range (before → after). The workflow should be triggered on push events rather than pull_request.

yaml
on:
  push:
    branches:
    - main
    - develop

jobs:
  lint-commits:
    uses: this-is-tobi/github-workflows/.github/workflows/lint-commits.yml@v0
    permissions:
      contents: read
    with:
      COMMITS_SOURCE: push