Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions github/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) {
payload = &PullRequestReviewEvent{}
case "PullRequestReviewCommentEvent":
payload = &PullRequestReviewCommentEvent{}
case "PullRequestTargetEvent":
payload = &PullRequestTargetEvent{}
case "PushEvent":
payload = &PushEvent{}
case "ReleaseEvent":
Expand Down
42 changes: 42 additions & 0 deletions github/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,48 @@ type PullRequestReviewCommentEvent struct {
Installation *Installation `json:"installation,omitempty"`
}

// PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled,
// unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review,
// locked, unlocked, a pull request review is requested, or a review request is removed.
// The Webhook event name is "pull_request_target".
//
// GitHub API docs: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
type PullRequestTargetEvent struct {
// Action is the action that was performed. Possible values are:
// "assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened",
// "ready_for_review", "locked", "unlocked", "review_requested" or "review_request_removed".
// If the action is "closed" and the "merged" key is "false", the pull request was closed with unmerged commits.
// If the action is "closed" and the "merged" key is "true", the pull request was merged.
// While webhooks are also triggered when a pull request is synchronized, Events API timelines
// don't include pull request events with the "synchronize" action.
Action *string `json:"action,omitempty"`
Assignee *User `json:"assignee,omitempty"`
Number *int `json:"number,omitempty"`
PullRequest *PullRequest `json:"pull_request,omitempty"`

// The following fields are only populated by Webhook events.
Changes *EditChange `json:"changes,omitempty"`
// RequestedReviewer is populated in "review_requested", "review_request_removed" event deliveries.
// A request affecting multiple reviewers at once is split into multiple
// such event deliveries, each with a single, different RequestedReviewer.
RequestedReviewer *User `json:"requested_reviewer,omitempty"`
// In the event that a team is requested instead of a user, "requested_team" gets sent in place of
// "requested_user" with the same delivery behavior.
RequestedTeam *Team `json:"requested_team,omitempty"`
Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`
Label *Label `json:"label,omitempty"` // Populated in "labeled" event deliveries.

// 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 when the Action is "synchronize".
Before *string `json:"before,omitempty"`
After *string `json:"after,omitempty"`
}

// PushEvent represents a git push to a GitHub repository.
//
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#push
Expand Down
112 changes: 112 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion github/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ var (
"project_card": "ProjectCardEvent",
"project_column": "ProjectColumnEvent",
"public": "PublicEvent",
"pull_request": "PullRequestEvent",
"pull_request_review": "PullRequestReviewEvent",
"pull_request_review_comment": "PullRequestReviewCommentEvent",
"pull_request": "PullRequestEvent",
"pull_request_target": "PullRequestTargetEvent",
"push": "PushEvent",
"repository": "RepositoryEvent",
"repository_dispatch": "RepositoryDispatchEvent",
Expand Down
4 changes: 4 additions & 0 deletions github/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ func TestParseWebHook(t *testing.T) {
payload: &PullRequestReviewCommentEvent{},
messageType: "pull_request_review_comment",
},
{
payload: &PullRequestTargetEvent{},
messageType: "pull_request_target",
},
{
payload: &PushEvent{},
messageType: "push",
Expand Down