diff --git a/README.md b/README.md index 6af159c..062957b 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIPHY_API_KEY: ${{ secrets.GIPHY_API_KEY }} GITHUB_REPOSITORY: ${{ github.repository }} - GITHUB_COMMENT_BODY: ${{ github.event.comment.body }} - GITHUB_COMMENT_ID: ${{ github.event.comment.id }} # not necessary if `override` is false GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }} + GITHUB_COMMENT_BODY: ${{ github.event.comment.body }} + GITHUB_COMMENT_ID: ${{ github.event.comment.id }} + GITHUB_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} GITHUB_REVIEW_BODY: ${{ github.event.review.body }} GITHUB_REVIEW_ID: ${{ github.event.review.id }} with: diff --git a/cmd/action-lgtm-reaction/main.go b/cmd/action-lgtm-reaction/main.go index 1164232..684b82d 100644 --- a/cmd/action-lgtm-reaction/main.go +++ b/cmd/action-lgtm-reaction/main.go @@ -14,16 +14,17 @@ import ( ) var ( - githubToken = os.Getenv("GITHUB_TOKEN") - giphyAPIKey = os.Getenv("GIPHY_API_KEY") - githubRepository = os.Getenv("GITHUB_REPOSITORY") - githubCommentBody = os.Getenv("GITHUB_COMMENT_BODY") - githubCommentID = os.Getenv("GITHUB_COMMENT_ID") - githubIssueNumber = os.Getenv("GITHUB_ISSUE_NUMBER") - githubReviewBody = os.Getenv("GITHUB_REVIEW_BODY") - githubReviewID = os.Getenv("GITHUB_REVIEW_ID") - trigger = os.Getenv("INPUT_TRIGGER") - override = os.Getenv("INPUT_OVERRIDE") + githubToken = os.Getenv("GITHUB_TOKEN") + giphyAPIKey = os.Getenv("GIPHY_API_KEY") + githubRepository = os.Getenv("GITHUB_REPOSITORY") + githubIssueNumber = os.Getenv("GITHUB_ISSUE_NUMBER") + githubCommentBody = os.Getenv("GITHUB_COMMENT_BODY") + githubCommentID = os.Getenv("GITHUB_COMMENT_ID") + githubPullRequestNumber = os.Getenv("GITHUB_PULL_REQUEST_NUMBER") + githubReviewBody = os.Getenv("GITHUB_REVIEW_BODY") + githubReviewID = os.Getenv("GITHUB_REVIEW_ID") + trigger = os.Getenv("INPUT_TRIGGER") + override = os.Getenv("INPUT_OVERRIDE") ) func main() { @@ -84,12 +85,11 @@ func main() { return } - number, err := strconv.Atoi(githubIssueNumber) - if err != nil { - exit("unable to convert string to int in issue number: %v\n", err) - } - if needCreateComment { + number, err := strconv.Atoi(githubIssueNumber) + if err != nil { + exit("unable to convert string to int in issue number: %v\n", err) + } if err := githubClient.CreateIssueComment(ctx, owner, repo, number, comment); err != nil { exit("unable to create issue comment: %v\n", err) } @@ -97,6 +97,10 @@ func main() { } if needUpdateReview { + number, err := strconv.Atoi(githubPullRequestNumber) + if err != nil { + exit("unable to convert string to int in issue number: %v\n", err) + } reviewID, err := strconv.Atoi(githubReviewID) if err != nil { exit("unable to convert string to int in review id: %v\n", err)