Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Fix bug when updating pull request review body (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
micnncim authored Oct 15, 2019
1 parent 358ec8b commit e7bb179
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 19 additions & 15 deletions cmd/action-lgtm-reaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -84,19 +85,22 @@ 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)
}
return
}

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)
Expand Down

0 comments on commit e7bb179

Please sign in to comment.