Repository: google/go-github
Pull request #2630 (2023-01-17 06:00:08)

Add workflow_name to WorkflowJob struct

google-cla[bot]: Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/google/go-github/pull/2630/checks?check_run_id=10690357159) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
akohring: Done

Patch:
diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go
index 1422fd47..b55f9aa7 100644
--- a/github/actions_workflow_jobs.go
+++ b/github/actions_workflow_jobs.go
@@ -45,6 +45,7 @@ type WorkflowJob struct {
 	RunnerGroupID   *int64   `json:"runner_group_id,omitempty"`
 	RunnerGroupName *string  `json:"runner_group_name,omitempty"`
 	RunAttempt      *int64   `json:"run_attempt,omitempty"`
+	WorkflowName    *string  `json:"workflow_name,omitempty"`
 }
 
 // Jobs represents a slice of repository action workflow job.
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 9017783e..400bde8c 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -20910,6 +20910,14 @@ func (w *WorkflowJob) GetURL() string {
 	return *w.URL
 }
 
+// GetWorkflowName returns the WorkflowName field if it's non-nil, zero value otherwise.
+func (w *WorkflowJob) GetWorkflowName() string {
+	if w == nil || w.WorkflowName == nil {
+		return ""
+	}
+	return *w.WorkflowName
+}
+
 // GetAction returns the Action field if it's non-nil, zero value otherwise.
 func (w *WorkflowJobEvent) GetAction() string {
 	if w == nil || w.Action == nil {


Test patch:
diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go
index 204f0014..da52619a 100644
--- a/github/actions_workflow_jobs_test.go
+++ b/github/actions_workflow_jobs_test.go
@@ -264,7 +264,8 @@ func TestWorkflowJob_Marshal(t *testing.T) {
 				CompletedAt: &Timestamp{referenceTime},
 			},
 		},
-		CheckRunURL: String("c"),
+		CheckRunURL:  String("c"),
+		WorkflowName: String("w"),
 	}
 
 	want := `{
@@ -288,7 +289,8 @@ func TestWorkflowJob_Marshal(t *testing.T) {
 			"started_at": ` + referenceTimeStr + `,
 			"completed_at": ` + referenceTimeStr + `
 		}],
-		"check_run_url": "c"
+		"check_run_url": "c",
+		"workflow_name": "w"
 	}`
 
 	testJSONMarshal(t, u, want)
@@ -323,8 +325,9 @@ func TestJobs_Marshal(t *testing.T) {
 						CompletedAt: &Timestamp{referenceTime},
 					},
 				},
-				CheckRunURL: String("c"),
-				RunAttempt:  Int64(2),
+				CheckRunURL:  String("c"),
+				RunAttempt:   Int64(2),
+				WorkflowName: String("w"),
 			},
 		},
 	}
@@ -353,7 +356,8 @@ func TestJobs_Marshal(t *testing.T) {
 				"completed_at": ` + referenceTimeStr + `
 			}],
 			"check_run_url": "c",
-			"run_attempt": 2
+			"run_attempt": 2,
+			"workflow_name": "w"
 		}]
 	}`
 
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index da69e263..3e4b4694 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -24443,6 +24443,16 @@ func TestWorkflowJob_GetURL(tt *testing.T) {
 	w.GetURL()
 }
 
+func TestWorkflowJob_GetWorkflowName(tt *testing.T) {
+	var zeroValue string
+	w := &WorkflowJob{WorkflowName: &zeroValue}
+	w.GetWorkflowName()
+	w = &WorkflowJob{}
+	w.GetWorkflowName()
+	w = nil
+	w.GetWorkflowName()
+}
+
 func TestWorkflowJobEvent_GetAction(tt *testing.T) {
 	var zeroValue string
 	w := &WorkflowJobEvent{Action: &zeroValue}