Skip to content

Commit 4c7b9ae

Browse files
committed
check_run and check_suite webhooks support
1 parent a1051fd commit 4c7b9ae

File tree

5 files changed

+821
-0
lines changed

5 files changed

+821
-0
lines changed

github/github.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type Event string
2828

2929
// GitHub hook types
3030
const (
31+
CheckRunEvent Event = "check_run"
32+
CheckSuiteEvent Event = "check_suite"
3133
CommitCommentEvent Event = "commit_comment"
3234
CreateEvent Event = "create"
3335
DeleteEvent Event = "delete"
@@ -162,6 +164,14 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
162164
}
163165

164166
switch gitHubEvent {
167+
case CheckRunEvent:
168+
var pl CheckRunPayload
169+
err = json.Unmarshal([]byte(payload), &pl)
170+
return pl, err
171+
case CheckSuiteEvent:
172+
var pl CheckSuitePayload
173+
err = json.Unmarshal([]byte(payload), &pl)
174+
return pl, err
165175
case CommitCommentEvent:
166176
var pl CommitCommentPayload
167177
err = json.Unmarshal([]byte(payload), &pl)

github/github_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,26 @@ func TestWebhooks(t *testing.T) {
133133
filename string
134134
headers http.Header
135135
}{
136+
{
137+
name: "CheckRunEvent",
138+
event: CheckRunEvent,
139+
typ: CheckRunPayload{},
140+
filename: "../testdata/github/check-run.json",
141+
headers: http.Header{
142+
"X-Github-Event": []string{"check_run"},
143+
"X-Hub-Signature": []string{"sha1=229f4920493b455398168cd86dc6b366064bdf3f"},
144+
},
145+
},
146+
{
147+
name: "CheckSuiteEvent",
148+
event: CheckSuiteEvent,
149+
typ: CheckSuitePayload{},
150+
filename: "../testdata/github/check-suite.json",
151+
headers: http.Header{
152+
"X-Github-Event": []string{"check_suite"},
153+
"X-Hub-Signature": []string{"sha1=250ad5a340f8d91e67dc5682342f3190fd2006a1"},
154+
},
155+
},
136156
{
137157
name: "CommitCommentEvent",
138158
event: CommitCommentEvent,

0 commit comments

Comments
 (0)