Skip to content

Commit 3185445

Browse files
committed
Support for github_app_authorization event.
1 parent 4f72f9c commit 3185445

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

github/github.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const (
7272
WorkflowDispatchEvent Event = "workflow_dispatch"
7373
WorkflowJobEvent Event = "workflow_job"
7474
WorkflowRunEvent Event = "workflow_run"
75+
GitHubAppAuthorizationEvent Event = "github_app_authorization"
7576
)
7677

7778
// EventSubtype defines a GitHub Hook Event subtype
@@ -340,6 +341,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
340341
var pl WorkflowRunPayload
341342
err = json.Unmarshal([]byte(payload), &pl)
342343
return pl, err
344+
case GitHubAppAuthorizationEvent:
345+
var pl GitHubAppAuthorizationPayload
346+
err = json.Unmarshal([]byte(payload), &pl)
347+
return pl, err
343348
default:
344349
return nil, fmt.Errorf("unknown event %s", gitHubEvent)
345350
}

github/github_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,16 @@ func TestWebhooks(t *testing.T) {
573573
"X-Hub-Signature": []string{"sha1=c54d046b1ce440bc3434c8de5ad73e0a630d7cbe"},
574574
},
575575
},
576+
{
577+
name: "GitHubAppAuthorizationEvent",
578+
event: GitHubAppAuthorizationEvent,
579+
typ: GitHubAppAuthorizationPayload{},
580+
filename: "../testdata/github/github-app-authorization.json",
581+
headers: http.Header{
582+
"X-Github-Event": []string{"github_app_authorization"},
583+
"X-Hub-Signature": []string{"sha1=4f18624a7fe3a9c525b51bdbd0e3da8230d753d6"},
584+
},
585+
},
576586
}
577587

578588
for _, tt := range tests {

github/payload.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6913,3 +6913,28 @@ type Step struct {
69136913
StartedAt time.Time `json:"started_at"`
69146914
CompletedAt time.Time `json:"completed_at"`
69156915
}
6916+
6917+
// GitHubAppAuthorizationPayload contains revoke action payload
6918+
type GitHubAppAuthorizationPayload struct {
6919+
Action string `json:"string"`
6920+
Sender struct {
6921+
Login string `json:"login"`
6922+
ID int64 `json:"id"`
6923+
NodeID string `json:"node_id"`
6924+
AvatarURL string `json:"avatar_url"`
6925+
GravatarID string `json:"gravatar_id"`
6926+
URL string `json:"url"`
6927+
HTMLURL string `json:"html_url"`
6928+
FollowersURL string `json:"followers_url"`
6929+
FollowingURL string `json:"following_url"`
6930+
GistsURL string `json:"gists_url"`
6931+
StarredURL string `json:"starred_url"`
6932+
SubscriptionsURL string `json:"subscriptions_url"`
6933+
OrganizationsURL string `json:"orranizations_url"`
6934+
ReposURL string `json:"repos_url"`
6935+
EventsURL string `json:"events_url"`
6936+
ReceivedEventsURL string `json:"received_events_url"`
6937+
Type string `json:"type"`
6938+
SiteAdmin bool `json:"site_admin"`
6939+
} `json:"sender"`
6940+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"action": "revoked",
3+
"sender": {
4+
"login": "pansachin",
5+
"id": 83265393,
6+
"node_id": "MDQ6VXNlcjgzMjY1Mzkz",
7+
"avatar_url": "https://avatars.githubusercontent.com/u/83265393?v=4",
8+
"gravatar_id": "",
9+
"url": "https://api.github.com/users/pansachin",
10+
"html_url": "https://github.com/pansachin",
11+
"followers_url": "https://api.github.com/users/pansachin/followers",
12+
"following_url": "https://api.github.com/users/pansachin/following{/other_user}",
13+
"gists_url": "https://api.github.com/users/pansachin/gists{/gist_id}",
14+
"starred_url": "https://api.github.com/users/pansachin/starred{/owner}{/repo}",
15+
"subscriptions_url": "https://api.github.com/users/pansachin/subscriptions",
16+
"organizations_url": "https://api.github.com/users/pansachin/orgs",
17+
"repos_url": "https://api.github.com/users/pansachin/repos",
18+
"events_url": "https://api.github.com/users/pansachin/events{/privacy}",
19+
"received_events_url": "https://api.github.com/users/pansachin/received_events",
20+
"type": "User",
21+
"site_admin": false
22+
}
23+
}

0 commit comments

Comments
 (0)