From 68533e9c065291b22c5ed16a4a90d0f96fabcf6e Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 31 Mar 2021 17:37:57 -0400 Subject: [PATCH] Add Workflow and WorkflowRun to WorkflowRunEvent --- github/event_types.go | 4 +++- github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/github/event_types.go b/github/event_types.go index 72ac53de81a..928da6e3d11 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -989,7 +989,9 @@ type WorkflowDispatchEvent struct { // // GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#workflow_run type WorkflowRunEvent struct { - Action *string `json:"action,omitempty"` + Action *string `json:"action,omitempty"` + Workflow *Workflow `json:"workflow,omitempty"` + WorkflowRun *WorkflowRun `json:"workflow_run,omitempty"` // The following fields are only populated by Webhook events. Org *Organization `json:"organization,omitempty"` diff --git a/github/github-accessors.go b/github/github-accessors.go index 86ca2526b3c..92966561af1 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -16372,6 +16372,22 @@ func (w *WorkflowRunEvent) GetSender() *User { return w.Sender } +// GetWorkflow returns the Workflow field. +func (w *WorkflowRunEvent) GetWorkflow() *Workflow { + if w == nil { + return nil + } + return w.Workflow +} + +// GetWorkflowRun returns the WorkflowRun field. +func (w *WorkflowRunEvent) GetWorkflowRun() *WorkflowRun { + if w == nil { + return nil + } + return w.WorkflowRun +} + // GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. func (w *WorkflowRuns) GetTotalCount() int { if w == nil || w.TotalCount == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 5be1c304ffe..1e1cf2f95bc 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -19224,6 +19224,20 @@ func TestWorkflowRunEvent_GetSender(tt *testing.T) { w.GetSender() } +func TestWorkflowRunEvent_GetWorkflow(tt *testing.T) { + w := &WorkflowRunEvent{} + w.GetWorkflow() + w = nil + w.GetWorkflow() +} + +func TestWorkflowRunEvent_GetWorkflowRun(tt *testing.T) { + w := &WorkflowRunEvent{} + w.GetWorkflowRun() + w = nil + w.GetWorkflowRun() +} + func TestWorkflowRuns_GetTotalCount(tt *testing.T) { var zeroValue int w := &WorkflowRuns{TotalCount: &zeroValue}