Skip to content

Commit 26af15f

Browse files
committed
Adding support for event integration_installation_repositories
1 parent 2c25dbc commit 26af15f

File tree

3 files changed

+125
-39
lines changed

3 files changed

+125
-39
lines changed

github/github.go

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,45 @@ 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-
OrganizationEvent Event = "organization"
50-
OrgBlockEvent Event = "org_block"
51-
PageBuildEvent Event = "page_build"
52-
PingEvent Event = "ping"
53-
ProjectCardEvent Event = "project_card"
54-
ProjectColumnEvent Event = "project_column"
55-
ProjectEvent Event = "project"
56-
PublicEvent Event = "public"
57-
PullRequestEvent Event = "pull_request"
58-
PullRequestReviewEvent Event = "pull_request_review"
59-
PullRequestReviewCommentEvent Event = "pull_request_review_comment"
60-
PushEvent Event = "push"
61-
ReleaseEvent Event = "release"
62-
RepositoryEvent Event = "repository"
63-
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
64-
SecurityAdvisoryEvent Event = "security_advisory"
65-
StatusEvent Event = "status"
66-
TeamEvent Event = "team"
67-
TeamAddEvent Event = "team_add"
68-
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+
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"
6970
)
7071

7172
// EventSubtype defines a GitHub Hook Event subtype
@@ -206,7 +207,7 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
206207
var pl InstallationPayload
207208
err = json.Unmarshal([]byte(payload), &pl)
208209
return pl, err
209-
case InstallationRepositoriesEvent:
210+
case InstallationRepositoriesEvent, IntegrationInstallationRepositoriesEvent:
210211
var pl InstallationRepositoriesPayload
211212
err = json.Unmarshal([]byte(payload), &pl)
212213
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,
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)