From 3af0adf975c46d2d10670d7d721a7e4459798485 Mon Sep 17 00:00:00 2001 From: GabrieleCalarota Date: Tue, 28 Sep 2021 16:52:25 +0200 Subject: [PATCH 1/6] Fix prefix_only --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index cb3a281..e81f5ca 100755 --- a/index.js +++ b/index.js @@ -32,7 +32,7 @@ async function run() { const prefixOnly = core.getInput("prefix_only") === 'true'; - if ((prefixOnly && !body.startsWith(trigger)) || !body.includes(trigger)) { + if ((prefixOnly && !body.startsWith(trigger)) || (!prefixOnly && !body.includes(trigger))) { core.setOutput("triggered", "false"); return; } From 535fb3dd0dc83df5be4e360d9c25f03fcc6ac732 Mon Sep 17 00:00:00 2001 From: GabrieleCalarota Date: Tue, 28 Sep 2021 16:55:43 +0200 Subject: [PATCH 2/6] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 9bb1da1..53c0628 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: 'Pull Request Comment Trigger' +name: 'Pull Request Comment Trigger v1.0.1' description: 'Look for a "trigger word" in a pull-request description or comment, so that later steps can know whether or not to run.' inputs: reaction: @@ -22,4 +22,4 @@ runs: main: 'dist/index.js' branding: icon: check-circle - color: red \ No newline at end of file + color: red From 42fb93e4265d110a654ea410847ee8f5c773c729 Mon Sep 17 00:00:00 2001 From: GabrieleCalarota Date: Tue, 28 Sep 2021 17:13:44 +0200 Subject: [PATCH 3/6] More logs --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e81f5ca..98fdfae 100755 --- a/index.js +++ b/index.js @@ -17,6 +17,8 @@ async function run() { context.eventName === "issue_comment" ? context.payload.comment.body : context.payload.pull_request.body; + + console.log(body); core.setOutput('comment_body', body); if ( @@ -32,11 +34,11 @@ async function run() { const prefixOnly = core.getInput("prefix_only") === 'true'; - if ((prefixOnly && !body.startsWith(trigger)) || (!prefixOnly && !body.includes(trigger))) { + if (!body.includes(trigger) || (prefixOnly && !body.startsWith(trigger)) ) { core.setOutput("triggered", "false"); return; } - + console.log(trigger); core.setOutput("triggered", "true"); if (!reaction) { From 2cc8a88292472d0b7109227b53b8dac91a22ed28 Mon Sep 17 00:00:00 2001 From: GabrieleCalarota Date: Wed, 6 Oct 2021 11:57:46 +0200 Subject: [PATCH 4/6] Update index.js --- index.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 98fdfae..67fa383 100755 --- a/index.js +++ b/index.js @@ -13,14 +13,6 @@ async function run() { return; } - const body = - context.eventName === "issue_comment" - ? context.payload.comment.body - : context.payload.pull_request.body; - - console.log(body); - core.setOutput('comment_body', body); - if ( context.eventName === "issue_comment" && !context.payload.issue.pull_request @@ -29,6 +21,11 @@ async function run() { core.setOutput("triggered", "false"); return; } + + const body = context.payload.pull_request.body; + + console.log(body); + core.setOutput('comment_body', body); const { owner, repo } = context.repo; From 3c47c5b187c004d1017e8d464b77e3b250d4e614 Mon Sep 17 00:00:00 2001 From: GabrieleCalarota Date: Wed, 6 Oct 2021 12:30:26 +0200 Subject: [PATCH 5/6] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 67fa383..0b89b01 100755 --- a/index.js +++ b/index.js @@ -21,8 +21,8 @@ async function run() { core.setOutput("triggered", "false"); return; } - - const body = context.payload.pull_request.body; + console.log(context.payload); + const body = context.payload.issue.body; console.log(body); core.setOutput('comment_body', body); From a71e8d5b873218e9705f8ecc2400d4029083ef57 Mon Sep 17 00:00:00 2001 From: Gabriele Calarota Date: Sun, 10 Oct 2021 13:56:03 +0200 Subject: [PATCH 6/6] Fixed if condition with prefix only --- .gitignore | 1 + index.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3c3629e..cd98105 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.idea/ \ No newline at end of file diff --git a/index.js b/index.js index 0b89b01..14a4248 100755 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ async function run() { const prefixOnly = core.getInput("prefix_only") === 'true'; - if (!body.includes(trigger) || (prefixOnly && !body.startsWith(trigger)) ) { + if ((prefixOnly && !body.startsWith(trigger)) || (!prefixOnly && !body.includes(trigger))) { core.setOutput("triggered", "false"); return; }