Skip to content

Commit ef903a2

Browse files
author
Dean Karn
authored
Merge branch 'v5' into github-meta-event
2 parents dc7efa3 + 115b7e4 commit ef903a2

File tree

4 files changed

+129
-40
lines changed

4 files changed

+129
-40
lines changed

github/github.go

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,46 @@ type Event string
2828

2929
// GitHub hook types
3030
const (
31-
CheckRunEvent Event = "check_run"
32-
CheckSuiteEvent Event = "check_suite"
33-
CommitCommentEvent Event = "commit_comment"
34-
CreateEvent Event = "create"
35-
DeleteEvent Event = "delete"
36-
DeploymentEvent Event = "deployment"
37-
DeploymentStatusEvent Event = "deployment_status"
38-
ForkEvent Event = "fork"
39-
GollumEvent Event = "gollum"
40-
InstallationEvent Event = "installation"
41-
InstallationRepositoriesEvent Event = "installation_repositories"
42-
IntegrationInstallationEvent Event = "integration_installation"
43-
IssueCommentEvent Event = "issue_comment"
44-
IssuesEvent Event = "issues"
45-
LabelEvent Event = "label"
46-
MemberEvent Event = "member"
47-
MembershipEvent Event = "membership"
48-
MilestoneEvent Event = "milestone"
49-
MetaEvent Event = "meta"
50-
OrganizationEvent Event = "organization"
51-
OrgBlockEvent Event = "org_block"
52-
PageBuildEvent Event = "page_build"
53-
PingEvent Event = "ping"
54-
ProjectCardEvent Event = "project_card"
55-
ProjectColumnEvent Event = "project_column"
56-
ProjectEvent Event = "project"
57-
PublicEvent Event = "public"
58-
PullRequestEvent Event = "pull_request"
59-
PullRequestReviewEvent Event = "pull_request_review"
60-
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
61-
PushEvent Event = "push"
62-
ReleaseEvent Event = "release"
63-
RepositoryEvent Event = "repository"
64-
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
65-
SecurityAdvisoryEvent Event = "security_advisory"
66-
StatusEvent Event = "status"
67-
TeamEvent Event = "team"
68-
TeamAddEvent Event = "team_add"
69-
WatchEvent Event = "watch"
31+
CheckRunEvent Event = "check_run"
32+
CheckSuiteEvent Event = "check_suite"
33+
CommitCommentEvent Event = "commit_comment"
34+
CreateEvent Event = "create"
35+
DeleteEvent Event = "delete"
36+
DeploymentEvent Event = "deployment"
37+
DeploymentStatusEvent Event = "deployment_status"
38+
ForkEvent Event = "fork"
39+
GollumEvent Event = "gollum"
40+
InstallationEvent Event = "installation"
41+
InstallationRepositoriesEvent Event = "installation_repositories"
42+
IntegrationInstallationEvent Event = "integration_installation"
43+
IntegrationInstallationRepositoriesEvent Event = "integration_installation_repositories"
44+
IssueCommentEvent Event = "issue_comment"
45+
IssuesEvent Event = "issues"
46+
LabelEvent Event = "label"
47+
MemberEvent Event = "member"
48+
MembershipEvent Event = "membership"
49+
MilestoneEvent Event = "milestone"
50+
MetaEvent Event = "meta"
51+
OrganizationEvent Event = "organization"
52+
OrgBlockEvent Event = "org_block"
53+
PageBuildEvent Event = "page_build"
54+
PingEvent Event = "ping"
55+
ProjectCardEvent Event = "project_card"
56+
ProjectColumnEvent Event = "project_column"
57+
ProjectEvent Event = "project"
58+
PublicEvent Event = "public"
59+
PullRequestEvent Event = "pull_request"
60+
PullRequestReviewEvent Event = "pull_request_review"
61+
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
62+
PushEvent Event = "push"
63+
ReleaseEvent Event = "release"
64+
RepositoryEvent Event = "repository"
65+
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
66+
SecurityAdvisoryEvent Event = "security_advisory"
67+
StatusEvent Event = "status"
68+
TeamEvent Event = "team"
69+
TeamAddEvent Event = "team_add"
70+
WatchEvent Event = "watch"
7071
)
7172

7273
// EventSubtype defines a GitHub Hook Event subtype
@@ -207,7 +208,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
207208
var pl InstallationPayload
208209
err = json.Unmarshal([]byte(payload), &pl)
209210
return pl, err
210-
case InstallationRepositoriesEvent:
211+
case InstallationRepositoriesEvent, IntegrationInstallationRepositoriesEvent:
211212
var pl InstallationRepositoriesPayload
212213
err = json.Unmarshal([]byte(payload), &pl)
213214
return pl, err

github/github_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,16 @@ func TestWebhooks(t *testing.T) {
253253
"X-Hub-Signature": []string{"sha1=bb2769f05f1a11af3a1edf8f9fac11bae7402a1e"},
254254
},
255255
},
256+
{
257+
name: "IntegrationInstallationRepositoriesEvent",
258+
event: IntegrationInstallationRepositoriesEvent,
259+
typ: InstallationRepositoriesPayload{},
260+
filename: "../testdata/github/integration-installation-repositories.json",
261+
headers: http.Header{
262+
"X-Github-Event": []string{"integration_installation_repositories"},
263+
"X-Hub-Signature": []string{"sha1=2f00a982574188342c2894eb9d1b1e93434687fb"},
264+
},
265+
},
256266
{
257267
name: "IssueCommentEvent",
258268
event: IssueCommentEvent,

github/payload.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5270,6 +5270,9 @@ type ReleasePayload struct {
52705270
Type string `json:"type"`
52715271
SiteAdmin bool `json:"site_admin"`
52725272
} `json:"sender"`
5273+
Installation struct {
5274+
ID int `json:"id"`
5275+
} `json:"installation"`
52735276
}
52745277

52755278
// RepositoryPayload contains the information for GitHub's repository hook event
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"action": "removed",
3+
"installation": {
4+
"id": 2,
5+
"account": {
6+
"login": "octocat",
7+
"id": 1,
8+
"node_id": "MDQ6VXNlcjE=",
9+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
10+
"gravatar_id": "",
11+
"url": "https://api.github.com/users/octocat",
12+
"html_url": "https://github.com/octocat",
13+
"followers_url": "https://api.github.com/users/octocat/followers",
14+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
15+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
16+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
17+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
18+
"organizations_url": "https://api.github.com/users/octocat/orgs",
19+
"repos_url": "https://api.github.com/users/octocat/repos",
20+
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
21+
"received_events_url": "https://api.github.com/users/octocat/received_events",
22+
"type": "User",
23+
"site_admin": false
24+
},
25+
"repository_selection": "selected",
26+
"access_tokens_url": "https://api.github.com/installations/2/access_tokens",
27+
"repositories_url": "https://api.github.com/installation/repositories",
28+
"html_url": "https://github.com/settings/installations/2",
29+
"app_id": 5725,
30+
"target_id": 3880403,
31+
"target_type": "User",
32+
"permissions": {
33+
"metadata": "read",
34+
"contents": "read",
35+
"issues": "write"
36+
},
37+
"events": [
38+
"push",
39+
"pull_request"
40+
],
41+
"created_at": 1525109898,
42+
"updated_at": 1525109899,
43+
"single_file_name": "config.yml"
44+
},
45+
"repository_selection": "selected",
46+
"repositories_added": [],
47+
"repositories_removed": [
48+
{
49+
"id": 1296269,
50+
"name": "Hello-World",
51+
"full_name": "octocat/Hello-World",
52+
"private": false
53+
}
54+
],
55+
"sender": {
56+
"login": "octocat",
57+
"id": 1,
58+
"node_id": "MDQ6VXNlcjE=",
59+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
60+
"gravatar_id": "",
61+
"url": "https://api.github.com/users/octocat",
62+
"html_url": "https://github.com/octocat",
63+
"followers_url": "https://api.github.com/users/octocat/followers",
64+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
65+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
66+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
67+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
68+
"organizations_url": "https://api.github.com/users/octocat/orgs",
69+
"repos_url": "https://api.github.com/users/octocat/repos",
70+
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
71+
"received_events_url": "https://api.github.com/users/octocat/received_events",
72+
"type": "User",
73+
"site_admin": false
74+
}
75+
}

0 commit comments

Comments
 (0)