From 6564f52ab4b7e8add161a34421eda9b8f36d474f Mon Sep 17 00:00:00 2001 From: Na-ga <537006+na-ga@users.noreply.github.com> Date: Wed, 5 Jan 2022 15:43:10 +0900 Subject: [PATCH] Add send message when validate failed (#21) --- main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f3dede8..42db306 100644 --- a/main.go +++ b/main.go @@ -36,12 +36,15 @@ func main() { if err != nil { log.Fatal(err.Error()) } - if err := validateEnv(e); err != nil { - log.Fatal(err.Error()) - } ctx, f := context.WithTimeout(context.Background(), jobTimeout) defer f() client := newGHClient(e.GithubToken) + if err := validateEnv(e); err != nil { + if serr := client.sendMsg(ctx, e.Owner, e.Repo, e.PRNumber, errMsg(err)); serr != nil { + log.Fatalf("failed to send message: %v original: %v", serr, err) + } + log.Fatal(err.Error()) + } if err := client.merge(ctx, e.Owner, e.Repo, e.PRNumber, e.MergeMethod); err != nil { if serr := client.sendMsg(ctx, e.Owner, e.Repo, e.PRNumber, errMsg(err)); serr != nil { log.Fatalf("failed to send message: %v original: %v", serr, err)