Repository: google/go-github
Pull request #2381 (2022-06-13 06:35:56)

Add Actor field to WorkflowRun
Add `Actor` field to `WorkflowRun`.
Fixes: https://github.com/google/go-github/issues/2380

codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2381?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2381](https://codecov.io/gh/google/go-github/pull/2381?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (3304574) into [master](https://codecov.io/gh/google/go-github/commit/0b5813fe43cc374cacb2e7492861af7d12199377?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (0b5813f) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##           master    #2381   +/-   ##
=======================================
  Coverage   98.06%   98.06%           
=======================================
  Files         119      119           
  Lines       10545    10545           
=======================================
  Hits        10341    10341           
  Misses        140      140           
  Partials       64       64           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2381?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/actions\_workflow\_runs.go](https://codecov.io/gh/google/go-github/pull/2381/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL2FjdGlvbnNfd29ya2Zsb3dfcnVucy5nbw==) | `100.00% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/2381?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/2381?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [0b5813f...3304574](https://codecov.io/gh/google/go-github/pull/2381?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/actions_workflow_runs.go b/github/actions_workflow_runs.go
index de1e6c27..18fdd57d 100644
--- a/github/actions_workflow_runs.go
+++ b/github/actions_workflow_runs.go
@@ -44,6 +44,7 @@ type WorkflowRun struct {
 	WorkflowURL        *string        `json:"workflow_url,omitempty"`
 	Repository         *Repository    `json:"repository,omitempty"`
 	HeadRepository     *Repository    `json:"head_repository,omitempty"`
+	Actor              *User          `json:"actor,omitempty"`
 }
 
 // WorkflowRuns represents a slice of repository action workflow run.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 774dc0bf..c1cb0d1f 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -19654,6 +19654,14 @@ func (w *WorkflowJobEvent) GetWorkflowJob() *WorkflowJob {
 	return w.WorkflowJob
 }
 
+// GetActor returns the Actor field.
+func (w *WorkflowRun) GetActor() *User {
+	if w == nil {
+		return nil
+	}
+	return w.Actor
+}
+
 // GetArtifactsURL returns the ArtifactsURL field if it's non-nil, zero value otherwise.
 func (w *WorkflowRun) GetArtifactsURL() string {
 	if w == nil || w.ArtifactsURL == nil {


Test patch:
diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go
index 12f50805..d22b8a52 100644
--- a/github/actions_workflow_runs_test.go
+++ b/github/actions_workflow_runs_test.go
@@ -638,6 +638,26 @@ func TestWorkflowRun_Marshal(t *testing.T) {
 			URL:  String("u"),
 			Name: String("n"),
 		},
+		Actor: &User{
+			Login:           String("l"),
+			ID:              Int64(1),
+			AvatarURL:       String("a"),
+			GravatarID:      String("g"),
+			Name:            String("n"),
+			Company:         String("c"),
+			Blog:            String("b"),
+			Location:        String("l"),
+			Email:           String("e"),
+			Hireable:        Bool(true),
+			Bio:             String("b"),
+			TwitterUsername: String("t"),
+			PublicRepos:     Int(1),
+			Followers:       Int(1),
+			Following:       Int(1),
+			CreatedAt:       &Timestamp{referenceTime},
+			SuspendedAt:     &Timestamp{referenceTime},
+			URL:             String("u"),
+		},
 	}
 
 	want := `{
@@ -718,6 +738,26 @@ func TestWorkflowRun_Marshal(t *testing.T) {
 			"id": 1,
 			"url": "u",
 			"name": "n"
+		},
+		"actor": {
+			"login": "l",
+			"id": 1,
+			"avatar_url": "a",
+			"gravatar_id": "g",
+			"name": "n",
+			"company": "c",
+			"blog": "b",
+			"location": "l",
+			"email": "e",
+			"hireable": true,
+			"bio": "b",
+			"twitter_username": "t",
+			"public_repos": 1,
+			"followers": 1,
+			"following": 1,
+			"created_at": ` + referenceTimeStr + `,
+			"suspended_at": ` + referenceTimeStr + `,
+			"url": "u"
 		}
 	}`
 
@@ -809,6 +849,26 @@ func TestWorkflowRuns_Marshal(t *testing.T) {
 					URL:  String("u"),
 					Name: String("n"),
 				},
+				Actor: &User{
+					Login:           String("l"),
+					ID:              Int64(1),
+					AvatarURL:       String("a"),
+					GravatarID:      String("g"),
+					Name:            String("n"),
+					Company:         String("c"),
+					Blog:            String("b"),
+					Location:        String("l"),
+					Email:           String("e"),
+					Hireable:        Bool(true),
+					Bio:             String("b"),
+					TwitterUsername: String("t"),
+					PublicRepos:     Int(1),
+					Followers:       Int(1),
+					Following:       Int(1),
+					CreatedAt:       &Timestamp{referenceTime},
+					SuspendedAt:     &Timestamp{referenceTime},
+					URL:             String("u"),
+				},
 			},
 		},
 	}
@@ -894,7 +954,27 @@ func TestWorkflowRuns_Marshal(t *testing.T) {
 					"id": 1,
 					"url": "u",
 					"name": "n"
-				}
+				},
+				"actor": {
+					"login": "l",
+					"id": 1,
+					"avatar_url": "a",
+					"gravatar_id": "g",
+					"name": "n",
+					"company": "c",
+					"blog": "b",
+					"location": "l",
+					"email": "e",
+					"hireable": true,
+					"bio": "b",
+					"twitter_username": "t",
+					"public_repos": 1,
+					"followers": 1,
+					"following": 1,
+					"created_at": ` + referenceTimeStr + `,
+					"suspended_at": ` + referenceTimeStr + `,
+					"url": "u"
+				}		
 			}
 		]
 	}`
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index f07c21b8..80134620 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -22978,6 +22978,13 @@ func TestWorkflowJobEvent_GetWorkflowJob(tt *testing.T) {
 	w.GetWorkflowJob()
 }
 
+func TestWorkflowRun_GetActor(tt *testing.T) {
+	w := &WorkflowRun{}
+	w.GetActor()
+	w = nil
+	w.GetActor()
+}
+
 func TestWorkflowRun_GetArtifactsURL(tt *testing.T) {
 	var zeroValue string
 	w := &WorkflowRun{ArtifactsURL: &zeroValue}