Skip to content

Commit

Permalink
Implement fallback if body is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed Feb 24, 2022
1 parent b708e17 commit 71e7761
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
19 changes: 10 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8051,21 +8051,22 @@ async function run() {
core.setOutput("triggered", "false");
return;
}
console.log(context.payload);
const body = context.payload.issue.body;

console.log(body);
core.setOutput('comment_body', body);
const body =
(context.eventName === "issue_comment"
? context.payload.comment.body
: context.payload.pull_request.body) || "";
core.setOutput("comment_body", body);

const { owner, repo } = context.repo;


const prefixOnly = core.getInput("prefix_only") === 'true';
if ((prefixOnly && !body.startsWith(trigger)) || (!prefixOnly && !body.includes(trigger))) {
const prefixOnly = core.getInput("prefix_only") === "true";
if (
(prefixOnly && !body.startsWith(trigger)) ||
(!prefixOnly && !body.includes(trigger))
) {
core.setOutput("triggered", "false");
return;
}
console.log(trigger);
core.setOutput("triggered", "true");

if (!reaction) {
Expand Down
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ async function run() {
core.setOutput("triggered", "false");
return;
}
console.log(context.payload);
const body = context.payload.issue.body;

console.log(body);
const body =
(context.eventName === "issue_comment"
? context.payload.comment.body
: context.payload.pull_request.body) || "";
core.setOutput("comment_body", body);

const { owner, repo } = context.repo;
Expand All @@ -37,7 +37,6 @@ async function run() {
core.setOutput("triggered", "false");
return;
}
console.log(trigger);
core.setOutput("triggered", "true");

if (!reaction) {
Expand Down

0 comments on commit 71e7761

Please sign in to comment.