Skip to content

Commit

Permalink
Merge pull request #141 from litscher/master
Browse files Browse the repository at this point in the history
allow for failure on blank description
  • Loading branch information
JJ authored Sep 9, 2024
2 parents f305466 + 93fa235 commit c684255
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ branding:
inputs:
github-token:
description: "Github token, added magically"
allowEmpty:
description: "Boolean - true will only throw a warning if the body is empty, false will fail the run"
default: true
bodyContains:
description: "String or |-separated array of strings, one of which must be contained in the PR body, can be left blank or omitted"
bodyDoesNotContain:
Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ async function run() {
// Check if the body contains required string
const bodyContains = core.getInput("bodyContains");
const bodyDoesNotContain = core.getInput("bodyDoesNotContain");
//Check if a description is required
const allowEmpty = core.getInput("allowEmpty");

if (
context.eventName !== "pull_request" &&
Expand All @@ -72,7 +74,13 @@ async function run() {
const PRBody = pull_request?.body;
core.info("Checking body contents");
if (!PRBody) {
core.warning("⚠️ The PR body is empty, skipping checks");
if(allowEmpty) {
core.warning("⚠️ The PR body is empty, skipping checks");
} else {
core.setFailed(
"❌ The PR body is empty. Please add info."
);
}
} else {
if (bodyContains && !rexify(bodyContains).test(PRBody)) {
core.setFailed(
Expand Down

0 comments on commit c684255

Please sign in to comment.