pr_title_lint_action

command module
v0.0.0-...-6905689 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Pull Request Lint

It is a linter of pull requests for GitHub Actions.

Why?

To enforce pull request titles in the same format will be useful like generating standard changelog messages. Besides it can be used to parse titles and link with issue tracking systems such as JIRA.

Example:

name: PR lint

on:
  pull_request:
    types: ['opened', 'edited', 'reopened', 'synchronize']

jobs:
  pr-lint:
    runs-on: golang:1.16.3
    steps:
    - uses: bonivan/pr-lint-action@master
      with:
        title-regex: '^\[PROJECT-\d*\](\ )'
        title-regex-flags: 'g' # optional
        error-message: 'Add Jira ID to your title' # optional
        exclude-files-regex: ''

In this example, for every pull request the title is expected to match ^\[PROJECT-\d*\]\ regex with a global flag g. For instance, [PROJECT-123] lorem ipsum or [PROJECT-2345] dolor sit amet are valid titles for this example. You can customize the title regex for your needs. The regex flags configuration is optional. exclude-files-regex is optional and is needed to suppress execution of title check if all files modified in this pull-request match that pattern.

Auto-close

It can be configured to close pull request automatically if the title does not match the pattern provided. To do so, github-token and auto-close-message options must be configured. In the message, %pattern% is replaced with the actual the pattern provided. Here is an example pull request.

Config:

name: PR lint

on:
  pull_request:
    types: ['opened', 'edited', 'reopened', 'synchronize']

jobs:
  pr-lint:
    runs-on: ubuntu-latest
    steps:
    - uses: seferov/pr-lint-action@master
      with:
        title-regex: '^\[PROJECT-\d*\](\ )'
+       github-token: ${{ secrets.GITHUB_TOKEN }}
+       auto-close-message: 'Closing this pull request since the title does not match %pattern% pattern. Please fix the title and re-open the pull request.'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL