Skip to content

Commit

Permalink
feat: body-fail option (#193)
Browse files Browse the repository at this point in the history
feat: body-fail option

adds body-fail input with a default value of false. If set to true
the action will show a failing check if PR body does not match
body-regex. By default, only a warning is registered.
  • Loading branch information
mtfoley authored May 15, 2022
1 parent 1fcc56a commit aefa3ef
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 101 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This action is meant to help in managing inbound PRs that may need adjustment ot
It looks for the following:
- [x] PR Title formatted according to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] PR Body refers to an issue, as detected by a regular expression
- [x] PR originates from a protected branch e.g. "main", (based on head ref)
- [x] PR includes modifications to specific files that should be reviewed carefully (e.g. package.json)
- [x] PR originates from a branch other than the protected branch, e.g. "main", (based on head ref)
- [x] PR does not include modifications to specific files that should be reviewed carefully (e.g. package.json)

## Sample Workflow File

Expand Down Expand Up @@ -60,7 +60,8 @@ repo-token | `secrets.GITHUB_TOKEN` | Access token for which this action will ru
ignore-authors | dependabot<br/>dependabot[bot] | If the action detects that the PR author is one of these logins, it will skip checks and set all outputs to `true`.
base-comment | (see [action.yml](./action.yml)) | Preamble to any comment the action leaves on the PR.
ignore-team-members | true | Whether to ignore in the case that the PR author is a) the owner of repository, or b) has a public membership[^1] in the org that owns the repository.
body-regex | `(fix\|resolv\|clos)(e)*(s\|d)* #\d+` | Regular expression to identify whether the PR body refers to an issue[^2].
body-regex | `(fix\|resolv\|clos)(e)*(s\|d)* #\d+` | Regular expression to identify whether the PR body refers to an issue[^2][^3].
body-fail | false | Whether to trigger a failing check when the body-regex is not matched in the PR body. Triggers a warning by default.
body-auto-close | true | Whether or not to auto-close on failed check of PR Body
body-comment | (see [action.yml](./action.yml)) | Comment to leave on PR on failed check of PR Body
protected-branch | (Blank) | Branch that check should ensure that PR does not use as it's head. If left blank, it falls back to default branch.
Expand All @@ -73,6 +74,7 @@ watch-files-comment | (see [action.yml](./action.yml)) | Comment to leave on PR

[^1]: In a case where a contributor has a private membership to the org, the `ignore-authors` may be used to skip checks - however, this workflow file configuration could effectively make membership public.
[^2]: Default regular expression is based on [linking to an issue using a keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword). To keep PRs related to issues within the same same repo, we use the `KEYWORD #ISSUE-NUMBER` syntax. However, one could also use a regular expression like `(fix\|resolv\|clos)(e)*(s|d)* (my-org)\/([a-z0-9\-_]*)#\d+`
[^3]: The body check can be configured to always pass by using a sufficiently generic regex, e.g. `.*`, that will match any PR description.

## Outputs

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ inputs:
required: true
description: 'PR Body Regex'
default: '(fix|resolv|clos)(e)*(s|d)* #\d+'
body-fail:
required: true
description: >
Whether to trigger a failing check when the body-regex is not matched in the PR body.
default: false
body-auto-close:
required: true
description: 'Whether or not to auto-close on failed check of PR Body'
Expand Down
Loading

0 comments on commit aefa3ef

Please sign in to comment.