From 0fc44c9a9ca5146dd6d8e6f2d7378160d4e45d50 Mon Sep 17 00:00:00 2001 From: micnncim Date: Wed, 16 Oct 2019 22:35:17 +0900 Subject: [PATCH] Fix bug in issue and pr number (#23) --- cmd/action-lgtm-reaction/main.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmd/action-lgtm-reaction/main.go b/cmd/action-lgtm-reaction/main.go index 6a4c4c3..0de1b65 100644 --- a/cmd/action-lgtm-reaction/main.go +++ b/cmd/action-lgtm-reaction/main.go @@ -101,9 +101,21 @@ func main() { } if needCreateComment { - number, err := strconv.Atoi(githubIssueNumber) - if err != nil { - exit("unable to convert string to int in issue number: %v\n", err) + if githubIssueNumber == "" && githubPullRequestNumber == "" { + exit("no issue number and pull request number\n") + } + var number int + var err error + if githubIssueNumber != "" { + number, err = strconv.Atoi(githubIssueNumber) + if err != nil { + exit("unable to convert string to int in issue number: %v\n", err) + } + } else if githubPullRequestNumber != "" { + number, err = strconv.Atoi(githubPullRequestNumber) + if err != nil { + exit("unable to convert string to int in pull request number: %v\n", err) + } } if err := githubClient.CreateIssueComment(ctx, owner, repo, number, comment); err != nil { exit("unable to create issue comment: %v\n", err)