Repository: google/go-github
Pull request #1840 (2021-03-31 21:38:32)

Add Workflow and WorkflowRun to WorkflowRunEvent
Fixes #1839.

gmlewis: @jacobfoard - PTAL.
codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=h1) Report
> Merging [#1840](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=desc) (68533e9) into [master](https://codecov.io/gh/google/go-github/commit/859ff4ca17317bef7ae2228cf4f9b54ca0107c08?el=desc) (859ff4c) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1840/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1840   +/-   ##
=======================================
  Coverage   97.56%   97.56%           
=======================================
  Files         104      104           
  Lines        6602     6602           
=======================================
  Hits         6441     6441           
  Misses         87       87           
  Partials       74       74           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/event\_types.go](https://codecov.io/gh/google/go-github/pull/1840/diff?src=pr&el=tree#diff-Z2l0aHViL2V2ZW50X3R5cGVzLmdv) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=footer). Last update [859ff4c...68533e9](https://codecov.io/gh/google/go-github/pull/1840?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/event_types.go b/github/event_types.go
index 72ac53de..928da6e3 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 86ca2526..92966561 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 {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 5be1c304..1e1cf2f9 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}