iamnotaturtle / pr-lint-action

:octocat: A fast πŸ”₯ TypeScript GitHub Action to ensure that your PR title matches a given regex.

Home Page:https://morrisoncole.co.uk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 πŸ› :

  • πŸ€– Review, request/dismiss changes, and comment with bot
  • ❌ Fail action

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.6.1
        with:
          title-regex: "#[eE][xX]-[0-9]+"
          on-failed-regex-fail-action: false
          on-failed-regex-request-changes: false
          on-failed-regex-create-review: true
          on-failed-regex-comment:
            "This is just an example. Failed regex: `%regex%`!"
          on-succeeded-regex-dismiss-review-comment:
            "This is just an example. Success!"
          repo-token: "${{ secrets.GITHUB_TOKEN }}"

Changelog

v1.6.0

  • Fixes #266: the success comment will now be created once the PR Lint succeeds, even when on-failed-regex-create-review is set to false. Thank you @talboren for reporting, debugging, and fixing this! πŸ’ͺ

v1.6.0

  • Updated documentation to recommend running the action on PR synchronize events too, so that the checks won't go stale.
  • Fixes #175: can now customize the success message when reviews are dismissed using on-succeeded-regex-dismiss-review-comment.
  • Fixes #171: run action with Node 16.
  • Upgrade dependencies.

v1.5.1

Internal refactoring only:

  • Migrate to Yarn 2.
  • Upgrade dependencies.

v1.5.0

  • Reduces action run time from around 40 seconds to 1 second πŸ”₯πŸš€. We now ship the packaged source with Vercel's ncc and run those directly rather than building on the fly with Docker.

v1.4.2

  • Fixes #155. Thanks to @ui-valts-mazurs for reporting and fixing this one!

v1.4.1

  • Fixes #145 (thanks @jnewland! 🀩).

v1.4.0

  • Adds #119 (thanks @bryantbiggs! πŸ™) the ability to configure whether changes are requested or not with on-failed-regex-request-changes. Existing behaviour is preserved.
  • Upgrades all dependencies.

v1.3.0

  • Adds #111, the ability to specify whether to create a review and whether to fail the action on a regex mismatch independently with on-failed-regex-fail-action & on-failed-regex-create-review.
  • on-failed-regex-comment is no longer a required input.

Note: existing behaviour from previous releases is preserved without additional configuration πŸ™.

v1.2.3

Internal refactoring only:

  • Upgrade dependencies.
  • Move from lib to dist.
  • Address ESLint warnings.

v1.2.2

v1.2.1

v1.1.1

Internal refactoring only:

  • Upgrade dependencies.
  • Configure ESLint & Prettier.

v1.1.0

  • Replaced status checks with an automatic bot review. If the PR title fails to match the regex, the bot will request changes. Once the title is edited to match it, the bot will dismiss its review.
  • Upgrade dependencies.

v1.0.0

  • Initial release. This version uses action status checks but suffers from #5 since the GitHub actions API treats different hook types as separate checks by default.

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

About

:octocat: A fast πŸ”₯ TypeScript GitHub Action to ensure that your PR title matches a given regex.

https://morrisoncole.co.uk

License:MIT License


Languages

Language:JavaScript 61.2%Language:TypeScript 38.8%