Skip to content

Commit

Permalink
Add support for projects_v2 and projects_v2_item webhook events (#2868)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin committed Aug 14, 2023
1 parent 5ac6057 commit 3ecf12c
Show file tree
Hide file tree
Showing 8 changed files with 1,101 additions and 0 deletions.
4 changes: 4 additions & 0 deletions github/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
payload = &ProjectCardEvent{}
case "ProjectColumnEvent":
payload = &ProjectColumnEvent{}
case "ProjectV2Event":
payload = &ProjectV2Event{}
case "ProjectV2ItemEvent":
payload = &ProjectV2ItemEvent{}
case "PublicEvent":
payload = &PublicEvent{}
case "PullRequestEvent":
Expand Down
71 changes: 71 additions & 0 deletions github/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,77 @@ type ProjectColumnEvent struct {
Installation *Installation `json:"installation,omitempty"`
}

// ProjectV2Event is triggered when there is activity relating to an organization-level project.
// The Webhook event name is "projects_v2".
//
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2
type ProjectV2Event struct {
Action *string `json:"action,omitempty"`
ProjectsV2 *ProjectsV2 `json:"projects_v2,omitempty"`

// The following fields are only populated by Webhook events.
Installation *Installation `json:"installation,omitempty"`
Org *Organization `json:"organization,omitempty"`
Sender *User `json:"sender,omitempty"`
}

// ProjectsV2 represents a projects v2 project.
type ProjectsV2 struct {
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Owner *User `json:"owner,omitempty"`
Creator *User `json:"creator,omitempty"`
Title *string `json:"title,omitempty"`
Description *string `json:"description,omitempty"`
Public *bool `json:"public,omitempty"`
ClosedAt *Timestamp `json:"closed_at,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
DeletedAt *Timestamp `json:"deleted_at,omitempty"`
Number *int `json:"number,omitempty"`
ShortDescription *string `json:"short_description,omitempty"`
DeletedBy *User `json:"deleted_by,omitempty"`
}

// ProjectV2ItemEvent is triggered when there is activity relating to an item on an organization-level project.
// The Webhook event name is "projects_v2_item".
//
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#projects_v2_item
type ProjectV2ItemEvent struct {
Action *string `json:"action,omitempty"`
Changes *ProjectV2ItemChange `json:"changes,omitempty"`
ProjectV2Item *ProjectV2Item `json:"projects_v2_item,omitempty"`

// The following fields are only populated by Webhook events.
Installation *Installation `json:"installation,omitempty"`
Org *Organization `json:"organization,omitempty"`
Sender *User `json:"sender,omitempty"`
}

// ProjectV2ItemChange represents a project v2 item change.
type ProjectV2ItemChange struct {
ArchivedAt *ArchivedAt `json:"archived_at,omitempty"`
}

// ArchivedAt represents an archiving date change.
type ArchivedAt struct {
From *Timestamp `json:"from,omitempty"`
To *Timestamp `json:"to,omitempty"`
}

// ProjectsV2 represents an item belonging to a project.
type ProjectV2Item struct {
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
ProjectNodeID *string `json:"project_node_id,omitempty"`
ContentNodeID *string `json:"content_node_id,omitempty"`
ContentType *string `json:"content_type,omitempty"`
Creator *User `json:"creator,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
ArchivedAt *Timestamp `json:"archived_at,omitempty"`
}

// PublicEvent is triggered when a private repository is open sourced.
// According to GitHub: "Without a doubt: the best GitHub event."
// The Webhook event name is "public".
Expand Down

0 comments on commit 3ecf12c

Please sign in to comment.