Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type Event string

// GitHub hook types
const (
CheckRunEvent Event = "check_run"
CheckSuiteEvent Event = "check_suite"
CommitCommentEvent Event = "commit_comment"
CreateEvent Event = "create"
DeleteEvent Event = "delete"
Expand Down Expand Up @@ -162,6 +164,14 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
}

switch gitHubEvent {
case CheckRunEvent:
var pl CheckRunPayload
err = json.Unmarshal([]byte(payload), &pl)
return pl, err
case CheckSuiteEvent:
var pl CheckSuitePayload
err = json.Unmarshal([]byte(payload), &pl)
return pl, err
case CommitCommentEvent:
var pl CommitCommentPayload
err = json.Unmarshal([]byte(payload), &pl)
Expand Down
20 changes: 20 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,26 @@ func TestWebhooks(t *testing.T) {
filename string
headers http.Header
}{
{
name: "CheckRunEvent",
event: CheckRunEvent,
typ: CheckRunPayload{},
filename: "../testdata/github/check-run.json",
headers: http.Header{
"X-Github-Event": []string{"check_run"},
"X-Hub-Signature": []string{"sha1=229f4920493b455398168cd86dc6b366064bdf3f"},
},
},
{
name: "CheckSuiteEvent",
event: CheckSuiteEvent,
typ: CheckSuitePayload{},
filename: "../testdata/github/check-suite.json",
headers: http.Header{
"X-Github-Event": []string{"check_suite"},
"X-Hub-Signature": []string{"sha1=250ad5a340f8d91e67dc5682342f3190fd2006a1"},
},
},
{
name: "CommitCommentEvent",
event: CommitCommentEvent,
Expand Down
Loading