Ok so PR's aren't working but I made it a little prettier.

This commit is contained in:
Sebastian Cabrera 2023-08-28 16:48:51 -04:00
parent 78c8955235
commit 268caa3d52

View file

@ -11,7 +11,7 @@ import (
)
// Wrap the shared transport for use with the integration ID and authenticating with installation ID.
var itr, err = ghinstallation.NewKeyFromFile(http.DefaultTransport, 381312, 41105280, "theopenestsource.2023-08-26.private-key.pem")
var itr, _ = ghinstallation.NewKeyFromFile(http.DefaultTransport, 381312, 41105280, "theopenestsource.2023-08-26.private-key.pem")
// Use installation transport with client.
var client = github.NewClient(&http.Client{Transport: itr})
@ -55,6 +55,8 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
panic(err)
}
w.WriteHeader(200)
switch event := event.(type) {
case *github.IssuesEvent:
processIssuesEvent(event)
@ -65,6 +67,9 @@ func webhookHandler(w http.ResponseWriter, r *http.Request) {
case *github.PullRequestReviewCommentEvent:
processPullRequestReviewCommentEvent(event)
break
default:
fmt.Println("Unhandled Event!")
break
}
}
@ -83,10 +88,10 @@ func processIssuesEvent(event *github.IssuesEvent) {
}
func processPullRequestEvent(event *github.PullRequestEvent) {
if event.GetAction() == "opened" {
if event.GetAction() == "opened" || event.GetAction() == "reopened" {
// Respond with a comment
comment := &github.IssueComment{
Body: github.String("React to this comment with +1 to vote for getting it merged!"),
Body: github.String("React to this comment with :+1: to vote for getting it merged!"),
}
_, _, err := client.Issues.CreateComment(ctx, event.GetRepo().GetOwner().GetLogin(), event.GetRepo().GetName(), event.GetPullRequest().GetNumber(), comment)
@ -94,10 +99,6 @@ func processPullRequestEvent(event *github.PullRequestEvent) {
log.Println("Error creating comment:", err)
}
}
if event.GetAction() == "reaction" {
}
}
func processPullRequestReviewCommentEvent(event *github.PullRequestReviewCommentEvent) {