From 399886cbca0abc4556eff6a4e3a4c35d5a6d9c14 Mon Sep 17 00:00:00 2001 From: TimmyCarbone Date: Fri, 2 Aug 2019 14:40:51 +0200 Subject: [PATCH 1/3] Check for existing notification before commenting --- entrypoint.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index f5425af..90c39ff 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,5 +29,13 @@ if !pr exit(1) end +coms = github.issue_comments(repo, pr["number"]) +duplicate = coms.find { |c| c["user"]["login"] == 'github-actions[bot]' and c["body"] == message } + +if duplicate + puts "The PR already contains a database change notification" + exit(0) +end + message = ARGV.join(' ') github.add_comment(repo, pr["number"], message) From d086f844342242ff99b7b32246de95031bd62f8e Mon Sep 17 00:00:00 2001 From: TimmyCarbone Date: Fri, 2 Aug 2019 14:57:40 +0200 Subject: [PATCH 2/3] Declare message before using it ... --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 90c39ff..a97a0c3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,6 +29,8 @@ if !pr exit(1) end +message = ARGV.join(' ') + coms = github.issue_comments(repo, pr["number"]) duplicate = coms.find { |c| c["user"]["login"] == 'github-actions[bot]' and c["body"] == message } @@ -37,5 +39,4 @@ if duplicate exit(0) end -message = ARGV.join(' ') github.add_comment(repo, pr["number"], message) From 393c0d7eb96380aaae15bd34af20ca14715df0a4 Mon Sep 17 00:00:00 2001 From: Aaron Klaassen Date: Mon, 30 Sep 2019 13:40:17 -0500 Subject: [PATCH 3/3] Use && rather than and. --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index a97a0c3..8ccee1a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -32,7 +32,7 @@ end message = ARGV.join(' ') coms = github.issue_comments(repo, pr["number"]) -duplicate = coms.find { |c| c["user"]["login"] == 'github-actions[bot]' and c["body"] == message } +duplicate = coms.find { |c| c["user"]["login"] == "github-actions[bot]" && c["body"] == message } if duplicate puts "The PR already contains a database change notification"