Home

Awesome

Pull Request Linter code style: prettier

:octocat: A fast 🔥 TypeScript GitHub Action to ensure that your PR title matches a given regex.

Supports the following feedback mechanisms 🛠:

Usage

Create a workflow definition at .github/workflows/<my-workflow>.yml with something like the following contents:

name: PR Lint

on:
  pull_request:
    # By default, a workflow only runs when a pull_request's activity type is opened, synchronize, or reopened. We
    # explicity override here so that PR titles are re-linted when the PR text content is edited.
    #
    # Possible values: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
    types: [opened, edited, reopened, synchronize]

jobs:
  pr-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: morrisoncole/pr-lint-action@v1.7.1
        with:
          # Note: if you have branch protection rules enabled, the `GITHUB_TOKEN` permissions
          # won't cover dismissing reviews. Your options are to pass in a custom token
          # (perhaps by creating some sort of 'service' user and creating a personal access
          # token with the correct permissions) or to turn off `on-failed-regex-request-changes`
          # and use action failure to prevent merges instead (with
          # `on-failed-regex-fail-action: true`). See:
          # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
          # https://docs.github.com/en/rest/pulls/reviews#dismiss-a-review-for-a-pull-request
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          title-regex: "#[eE][xX]-[0-9]+"
          on-failed-regex-fail-action: false
          on-failed-regex-create-review: true
          on-failed-regex-request-changes: false
          on-failed-regex-comment:
            "This is just an example. Failed regex: `%regex%`!"
          on-succeeded-regex-dismiss-review-comment:
            "This is just an example. Success!"

Options

OptionRequired?TypeDefault ValueDescription
repo-tokenyesstringN/AAbout the GITHUB_TOKEN secret.
title-regexyesstring".*"A JavaScript regex to test the title of each Pull Request against. Allows anything by default.
on-failed-regex-fail-actionnobooltrueIf the regex fails, sets the action status to failed. When the action exits it will be with an exit code of 1.
on-failed-regex-create-reviewnobooltrueIf the regex fails, uses the GitHub review mechanism to submit a review. The review type is determined by on-failed-regex-request-changes.
on-failed-regex-request-changesnobooltrueUses 'Request Changes' when creating a review. Otherwise, uses 'Comment'. Note: if on-failed-regex-create-review is false, this won't do anything.
on-failed-regex-commentnostring"PR title failed to match %regex%"Comment for the bot to post on PRs that fail the regex (or the console output if on-failed-regex-create-review is false). Use %regex% to reference regex.
on-succeeded-regex-dismiss-review-commentnostring"All good!"The message to post as a comment when the regex succeeds after previously failing.

Changelog

v1.7.1

v1.7.0

v1.6.1

v1.6.0

v1.5.1

Internal refactoring only:

v1.5.0

v1.4.2

v1.4.1

v1.4.0

v1.3.0

Note: existing behaviour from previous releases is preserved without additional configuration 🙏.

v1.2.3

Internal refactoring only:

v1.2.2

v1.2.1

v1.1.1

Internal refactoring only:

v1.1.0

v1.0.0

FAQ

Why doesn't this Action use status checks any more?

Since actions are currently not grouped together, previously failed status checks were persisted despite newer runs succeeding (reported in #5). We made the decision to use a bot-based 'request changes' workflow for the time being.

Developing

Build & Package

yarn install

yarn build

yarn package: We package everything to a single file with Vercel's ncc. Outputs to dist/index.js.

Validate Renovate Config

npx --package renovate -c renovate-config-validator

Related Reading