Skip to content

Workflow pr title lint

github-actions[bot] edited this page Nov 14, 2026 · 2 revisions

pr-title-lint

What it does. Fails a pull request when its title is too long or does not fully match a Python regular expression. It reads the title from the event payload, checks out no repository code and holds no token. Calls made by another event print a notice and do nothing.

Why it exists. A title becomes the squash commit subject and the release history. A local hook cannot govern a title typed in GitHub, while a reusable check gives every opt-in repository the same visible branch-protection result.

Default rule

The default accepts 8 to 120 Unicode characters, starts with a common imperative verb, contains no newline and does not end in a period. Endings such as (Refs #12) and (Closes #12) are valid. max-length is enforced separately and before regular expression matching.

pattern replaces the default and is applied with re.fullmatch. allow-prefixes is a comma-separated list such as release:,chore(deps):; a matching prefix bypasses the pattern, never the length limit.

A minimal caller

on:
  pull_request:

permissions: {}

jobs:
  title:
    uses: ChiefGyk3D/git-your-ship-together/.github/workflows/pr-title-lint.yml@<sha> # vX.Y.Z
    permissions: {}
    with:
      allow-prefixes: "release:,chore(deps):"

The workflow itself is callable, so GitHub preserves the caller's event. If a caller invokes it from push, schedule or workflow_dispatch, the job prints a notice and succeeds without inspecting a title.

Hostile titles and expressions

The title is passed through PR_TITLE, never inserted into a shell program. Workflow-command metacharacters and line breaks are escaped before an annotation prints the title, the broken rule, the fix and character counts.

Length is checked before the regular expression. Python's re has no timeout argument, so the Linux job uses the stdlib POSIX interval timer (signal.setitimer) to interrupt re.fullmatch after 0.25 seconds. A malformed or timed-out expression is a configuration error with a clear annotation and no traceback. scripts/check_pr_title.py is the local, stdlib-only source; the workflow carries it byte for byte because a reusable workflow cannot read a file from its own pinned commit.

Inputs (8), read from pr-title-lint.yml:

Input Type Default Meaning
pattern string (?=.{8,120}\Z)(?:Add|Adjust|Allow|Avoid|Build|Bump|Change|Clean|Document|Drop|Enable|Enforce|Ensure|Expose|Extend|Fix|Handle|Harden|Implement|Improve|Introduce|Make|Move|Prevent|Refactor|Release|Remove|Rename|Replace|Require|Restore|Revert|Simplify|Support|Test|Update|Upgrade|Use|Write)\b[^\r\n]*[^.\r\n]\Z Python-compatible regular expression matched against the whole title. The default requires an imperative-style title of 8 to 120 characters with no trailing period; `(Refs
max-length number 120 Maximum title length in Unicode characters, enforced before prefix or regular-expression matching.
allow-prefixes string empty Comma-separated prefixes allowed to bypass the pattern, for example release:,chore(deps):. They never bypass max-length.
egress-policy string block harden-runner egress policy - audit logs outbound connections, block allows only allowed-endpoints.
egress-policy-secretless string block Accepted so callers can pass the standard egress inputs; this secretless job follows this value.
allowed-endpoints string api.github.com:443 github.com:443 harden-runner allow-list for block, space-separated host:port entries. The defaults are the hosts the job's own steps (checkout, harden-runner) reach; they stay as they were.
extra-allowed-endpoints string empty Additional space-separated host:port entries appended to allowed-endpoints.
timeout-minutes number 5 Job timeout.

What it refuses to do

It never checks out or runs pull request code, never reads a secret, never interpolates the event title into shell source, never lets a prefix bypass the length ceiling, and never attempts a regular expression on an overlong title.

Clone this wiki locally