diff --git a/Dockerfile b/Dockerfile
index 4558842..c9109cf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,7 +20,6 @@ COPY --from=builder /go/src/github.com/Azure/spec-sla-bot/templates templates/
# Comment out to run the binary in "production" mode:
# ENV GO_ENV=production
-
# Bind the app to 0.0.0.0 so it can be seen from outside the container
ENV ADDR=0.0.0.0
diff --git a/actions/event.go b/actions/event.go
index e8e4926..802285f 100644
--- a/actions/event.go
+++ b/actions/event.go
@@ -1,18 +1,39 @@
package actions
import (
- "net/http"
+ "fmt"
+ "log"
- "github.com/Azure/spec-sla-bot/email"
"github.com/gobuffalo/buffalo"
+ "github.com/google/go-github/github"
)
// EventListen default implementation.
func EventListen(c buffalo.Context) error {
- errEmail := email.SendEmailToAssignee()
+ /*errEmail := email.SendEmailToAssignee()
if errEmail != nil {
c.Error(http.StatusInternalServerError, errEmail)
return errEmail
+ }*/ //handle secret
+ request := c.Request()
+ payload, err := github.ValidatePayload(request, []byte("Secret-Key"))
+ defer request.Body.Close()
+ event, err := github.ParseWebHook(github.WebHookType(request), payload)
+ if err != nil {
+ log.Printf("could not parse webhook: err=%s\n", err)
+ return err
}
- return c.Render(200, r.JSON(map[string]string{"message": "Welcome to Buffalo!"}))
+ repoName := ""
+ switch e := event.(type) {
+ case *github.PullRequestEvent:
+ if e.Action != nil {
+ repoName = *e.Repo.FullName
+ fmt.Printf("Repository Name: %s", *e.Repo.FullName)
+ }
+ default:
+ log.Printf("unknown event type %s\n", github.WebHookType(request))
+ return err
+ }
+
+ return c.Render(200, r.JSON(map[string]string{"message": "Welcome to Buffalo!", "Repository Name": repoName}))
}
diff --git a/actions/event_test.go b/actions/event_test.go
index d927805..d2ad2de 100644
--- a/actions/event_test.go
+++ b/actions/event_test.go
@@ -1,11 +1,5 @@
package actions
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
func (as *ActionSuite) Test_Event_Listen() {
as.Fail("Not Implemented!")
}
diff --git a/finalTemplate.html b/finalTemplate.html
index f3b3b77..624d85a 100644
--- a/finalTemplate.html
+++ b/finalTemplate.html
@@ -18,6 +18,54 @@ Current Requests: