Repository: google/go-github (go)

Issue:
Update DeployKeyEvent to include repo/org objects
For a while now it looks like the DeployKeyEvent has also sent along the repo and org objects related to the key https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deploy_key

Pull request description:
Add Repo and Org fields to DeployKeyEvent
Fixes #2279 

Patch:
diff --git a/github/event_types.go b/github/event_types.go
index 6a806c4a..c2382883 100644
--- a/github/event_types.go
+++ b/github/event_types.go
@@ -145,7 +145,15 @@ type DeployKeyEvent struct {
 	// The deploy key resource.
 	Key *Key `json:"key,omitempty"`
 
+	// The Repository where the event occurred
+	Repo *Repository `json:"repository,omitempty"`
+
+	// The following field is only present when the webhook is triggered on
+	// a repository belonging to an organization.
+	Organization *Organization `json:"organization,omitempty"`
+
 	// The following fields are only populated by Webhook events.
+	Sender       *User         `json:"sender,omitempty"`
 	Installation *Installation `json:"installation,omitempty"`
 }
 
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 96cfbc59..4bc74e57 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -3444,6 +3444,30 @@ func (d *DeployKeyEvent) GetKey() *Key {
 	return d.Key
 }
 
+// GetOrganization returns the Organization field.
+func (d *DeployKeyEvent) GetOrganization() *Organization {
+	if d == nil {
+		return nil
+	}
+	return d.Organization
+}
+
+// GetRepo returns the Repo field.
+func (d *DeployKeyEvent) GetRepo() *Repository {
+	if d == nil {
+		return nil
+	}
+	return d.Repo
+}
+
+// GetSender returns the Sender field.
+func (d *DeployKeyEvent) GetSender() *User {
+	if d == nil {
+		return nil
+	}
+	return d.Sender
+}
+
 // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
 func (d *Deployment) GetCreatedAt() Timestamp {
 	if d == nil || d.CreatedAt == nil {


Test patch:
diff --git a/github/event_types_test.go b/github/event_types_test.go
index 221d20c5..67cc1171 100644
--- a/github/event_types_test.go
+++ b/github/event_types_test.go
@@ -10220,6 +10220,42 @@ func TestDeployKeyEvent_Marshal(t *testing.T) {
 			Verified:  Bool(false),
 			CreatedAt: &Timestamp{referenceTime},
 		},
+		Repo: &Repository{
+			ID:   Int64(1),
+			URL:  String("s"),
+			Name: String("n"),
+		},
+		Organization: &Organization{
+			BillingEmail:                         String("be"),
+			Blog:                                 String("b"),
+			Company:                              String("c"),
+			Email:                                String("e"),
+			TwitterUsername:                      String("tu"),
+			Location:                             String("loc"),
+			Name:                                 String("n"),
+			Description:                          String("d"),
+			IsVerified:                           Bool(true),
+			HasOrganizationProjects:              Bool(true),
+			HasRepositoryProjects:                Bool(true),
+			DefaultRepoPermission:                String("drp"),
+			MembersCanCreateRepos:                Bool(true),
+			MembersCanCreateInternalRepos:        Bool(true),
+			MembersCanCreatePrivateRepos:         Bool(true),
+			MembersCanCreatePublicRepos:          Bool(false),
+			MembersAllowedRepositoryCreationType: String("marct"),
+			MembersCanCreatePages:                Bool(true),
+			MembersCanCreatePublicPages:          Bool(false),
+			MembersCanCreatePrivatePages:         Bool(true),
+		},
+		Sender: &User{
+			Login:     String("l"),
+			ID:        Int64(1),
+			NodeID:    String("n"),
+			AvatarURL: String("a"),
+			URL:       String("u"),
+			EventsURL: String("e"),
+			ReposURL:  String("r"),
+		},
 	}
 
 	want := `{
@@ -10232,6 +10268,42 @@ func TestDeployKeyEvent_Marshal(t *testing.T) {
 			"read_only": false,
 			"verified": false,
 			"created_at": ` + referenceTimeStr + `
+		},
+		"repository": {
+			"id": 1,
+			"name": "n",
+			"url": "s"
+		},
+		"organization": {
+			"name": "n",
+			"company": "c",
+			"blog": "b",
+			"location": "loc",
+			"email": "e",
+			"twitter_username": "tu",
+			"description": "d",
+			"billing_email": "be",
+			"is_verified": true,
+			"has_organization_projects": true,
+			"has_repository_projects": true,
+			"default_repository_permission": "drp",
+			"members_can_create_repositories": true,
+			"members_can_create_public_repositories": false,
+			"members_can_create_private_repositories": true,
+			"members_can_create_internal_repositories": true,
+			"members_allowed_repository_creation_type": "marct",
+			"members_can_create_pages": true,
+			"members_can_create_public_pages": false,
+			"members_can_create_private_pages": true
+		},
+		"sender": {
+			"login": "l",
+			"id": 1,
+			"node_id": "n",
+			"avatar_url": "a",
+			"url": "u",
+			"events_url": "e",
+			"repos_url": "r"
 		}
 	}`
 
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 4aa6d6df..3c480f4e 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -4027,6 +4027,27 @@ func TestDeployKeyEvent_GetKey(tt *testing.T) {
 	d.GetKey()
 }
 
+func TestDeployKeyEvent_GetOrganization(tt *testing.T) {
+	d := &DeployKeyEvent{}
+	d.GetOrganization()
+	d = nil
+	d.GetOrganization()
+}
+
+func TestDeployKeyEvent_GetRepo(tt *testing.T) {
+	d := &DeployKeyEvent{}
+	d.GetRepo()
+	d = nil
+	d.GetRepo()
+}
+
+func TestDeployKeyEvent_GetSender(tt *testing.T) {
+	d := &DeployKeyEvent{}
+	d.GetSender()
+	d = nil
+	d.GetSender()
+}
+
 func TestDeployment_GetCreatedAt(tt *testing.T) {
 	var zeroValue Timestamp
 	d := &Deployment{CreatedAt: &zeroValue}