Merge pull request #22 from rowbawts/test

Merging based on reactions
This commit is contained in:
openest-source-bot[bot] 2023-08-28 23:18:57 +00:00 committed by GitHub
commit 0cfea8c068
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,8 +103,9 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
for _, comment := range comments { for _, comment := range comments {
if strings.Contains(comment.GetBody(), "+1") && !strings.Contains(comment.GetUser().GetLogin(), "bot") { if strings.Contains(comment.GetBody(), "+1") && !strings.Contains(comment.GetUser().GetLogin(), "bot") {
fmt.Println(comment.GetUser().GetLogin()) fmt.Println(comment.GetUser().GetLogin())
return
reactionCount++ reactionCount++
}
}
if reactionCount >= reactionCountGoal { if reactionCount >= reactionCountGoal {
// Merge the pull request // Merge the pull request
@ -112,7 +113,17 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
MergeMethod: "merge", // Change this as needed MergeMethod: "merge", // Change this as needed
} }
_, _, err := client.PullRequests.Merge(ctx, owner, repo, prNumber, "Merging based on reactions", merge) // Respond with a comment
comment := &github.IssueComment{
Body: github.String("Merging based on reactions :fireworks:"),
}
_, _, err := client.Issues.CreateComment(ctx, owner, repo, prNumber, comment)
if err != nil {
log.Println("Error creating comment:", err)
}
_, _, err = client.PullRequests.Merge(ctx, owner, repo, prNumber, "Merging based on reactions", merge)
if err != nil { if err != nil {
log.Println("Error merging pull request:", err) log.Println("Error merging pull request:", err)
} else { } else {
@ -136,8 +147,6 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
} }
} }
} }
}
}
} }
func processPullRequestEvent(event *github.PullRequestEvent) { func processPullRequestEvent(event *github.PullRequestEvent) {