From f068af8a262f029e9cb3f414dca9e511e3913f20 Mon Sep 17 00:00:00 2001 From: Takumaron Date: Wed, 8 Nov 2023 16:37:25 +0700 Subject: [PATCH 1/3] Handle plan preview workflow's error and exit with error status code Signed-off-by: Takumaron --- tool/actions-plan-preview/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tool/actions-plan-preview/main.go b/tool/actions-plan-preview/main.go index 0bf0ecdcc3..dcdffafd94 100644 --- a/tool/actions-plan-preview/main.go +++ b/tool/actions-plan-preview/main.go @@ -139,6 +139,9 @@ func main() { doComment(failureBadgeURL + "\nUnable to run plan-preview for a closed pull request.") return } + body := makeCommentBody(event, result) + doComment(failureBadgeURL + body) + log.Fatal("plan-preview result has error") } // Find comments we sent before From b00eec6daca90f7d6a71e7b3ec5ddb14a3f4da1e Mon Sep 17 00:00:00 2001 From: Takumaron Date: Fri, 10 Nov 2023 08:31:49 +0700 Subject: [PATCH 2/3] Add line break Signed-off-by: Takumaron --- tool/actions-plan-preview/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/actions-plan-preview/main.go b/tool/actions-plan-preview/main.go index dcdffafd94..c026663a05 100644 --- a/tool/actions-plan-preview/main.go +++ b/tool/actions-plan-preview/main.go @@ -140,7 +140,7 @@ func main() { return } body := makeCommentBody(event, result) - doComment(failureBadgeURL + body) + doComment(failureBadgeURL + "\n" + body) log.Fatal("plan-preview result has error") } From 23a79cdea1772ebe9512a799ecd87c872d4604d3 Mon Sep 17 00:00:00 2001 From: Takumaron Date: Fri, 10 Nov 2023 10:54:32 +0700 Subject: [PATCH 3/3] Use `os.Exit(1)` explicitly Signed-off-by: Takumaron --- tool/actions-plan-preview/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tool/actions-plan-preview/main.go b/tool/actions-plan-preview/main.go index c026663a05..bcb94c95fe 100644 --- a/tool/actions-plan-preview/main.go +++ b/tool/actions-plan-preview/main.go @@ -141,7 +141,8 @@ func main() { } body := makeCommentBody(event, result) doComment(failureBadgeURL + "\n" + body) - log.Fatal("plan-preview result has error") + log.Println("plan-preview result has error") + os.Exit(1) } // Find comments we sent before