/
main.go
39 lines (31 loc) · 908 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"os"
"flag"
"github.com/ewgRa/ci-utils/src/github/comments"
"github.com/ewgRa/ci-utils/src/github/review"
"github.com/google/go-github/github"
)
// Send review
func main() {
body := flag.String("body", "", "The body text of the pull request review")
file := flag.String("file", "", "Comments, that you want to send to github")
repo := flag.String("repo", "", "Repository slug")
pr := flag.Int("pr", 0, "Pull request number")
flag.Parse()
if *file == "" || *pr == 0 || *repo == "" || *body == "" {
flag.Usage()
os.Exit(1)
}
commentsList := comments.ReadComments(*file)
event := "REQUEST_CHANGES"
reviewRequest := &github.PullRequestReviewRequest{
Body: body,
Event: &event,
Comments: commentsList.ToDraftReviewComments(),
}
err := review.SendReview(os.Getenv("GITHUB_COMMENTS_SEND_TOKEN"), *repo, *pr, reviewRequest)
if err != nil {
panic(err)
}
}