Skip to content

Commit 5b34ea7

Browse files
authored
Add referenced workflows to WorkflowRun (#2975)
Fixes: #2974.
1 parent 66ed84d commit 5b34ea7

File tree

4 files changed

+109
-34
lines changed

4 files changed

+109
-34
lines changed

github/actions_workflow_runs.go

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,40 @@ import (
1414

1515
// WorkflowRun represents a repository action workflow run.
1616
type WorkflowRun struct {
17-
ID *int64 `json:"id,omitempty"`
18-
Name *string `json:"name,omitempty"`
19-
NodeID *string `json:"node_id,omitempty"`
20-
HeadBranch *string `json:"head_branch,omitempty"`
21-
HeadSHA *string `json:"head_sha,omitempty"`
22-
RunNumber *int `json:"run_number,omitempty"`
23-
RunAttempt *int `json:"run_attempt,omitempty"`
24-
Event *string `json:"event,omitempty"`
25-
DisplayTitle *string `json:"display_title,omitempty"`
26-
Status *string `json:"status,omitempty"`
27-
Conclusion *string `json:"conclusion,omitempty"`
28-
WorkflowID *int64 `json:"workflow_id,omitempty"`
29-
CheckSuiteID *int64 `json:"check_suite_id,omitempty"`
30-
CheckSuiteNodeID *string `json:"check_suite_node_id,omitempty"`
31-
URL *string `json:"url,omitempty"`
32-
HTMLURL *string `json:"html_url,omitempty"`
33-
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
34-
CreatedAt *Timestamp `json:"created_at,omitempty"`
35-
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
36-
RunStartedAt *Timestamp `json:"run_started_at,omitempty"`
37-
JobsURL *string `json:"jobs_url,omitempty"`
38-
LogsURL *string `json:"logs_url,omitempty"`
39-
CheckSuiteURL *string `json:"check_suite_url,omitempty"`
40-
ArtifactsURL *string `json:"artifacts_url,omitempty"`
41-
CancelURL *string `json:"cancel_url,omitempty"`
42-
RerunURL *string `json:"rerun_url,omitempty"`
43-
PreviousAttemptURL *string `json:"previous_attempt_url,omitempty"`
44-
HeadCommit *HeadCommit `json:"head_commit,omitempty"`
45-
WorkflowURL *string `json:"workflow_url,omitempty"`
46-
Repository *Repository `json:"repository,omitempty"`
47-
HeadRepository *Repository `json:"head_repository,omitempty"`
48-
Actor *User `json:"actor,omitempty"`
49-
TriggeringActor *User `json:"triggering_actor,omitempty"`
17+
ID *int64 `json:"id,omitempty"`
18+
Name *string `json:"name,omitempty"`
19+
NodeID *string `json:"node_id,omitempty"`
20+
HeadBranch *string `json:"head_branch,omitempty"`
21+
HeadSHA *string `json:"head_sha,omitempty"`
22+
RunNumber *int `json:"run_number,omitempty"`
23+
RunAttempt *int `json:"run_attempt,omitempty"`
24+
Event *string `json:"event,omitempty"`
25+
DisplayTitle *string `json:"display_title,omitempty"`
26+
Status *string `json:"status,omitempty"`
27+
Conclusion *string `json:"conclusion,omitempty"`
28+
WorkflowID *int64 `json:"workflow_id,omitempty"`
29+
CheckSuiteID *int64 `json:"check_suite_id,omitempty"`
30+
CheckSuiteNodeID *string `json:"check_suite_node_id,omitempty"`
31+
URL *string `json:"url,omitempty"`
32+
HTMLURL *string `json:"html_url,omitempty"`
33+
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
34+
CreatedAt *Timestamp `json:"created_at,omitempty"`
35+
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
36+
RunStartedAt *Timestamp `json:"run_started_at,omitempty"`
37+
JobsURL *string `json:"jobs_url,omitempty"`
38+
LogsURL *string `json:"logs_url,omitempty"`
39+
CheckSuiteURL *string `json:"check_suite_url,omitempty"`
40+
ArtifactsURL *string `json:"artifacts_url,omitempty"`
41+
CancelURL *string `json:"cancel_url,omitempty"`
42+
RerunURL *string `json:"rerun_url,omitempty"`
43+
PreviousAttemptURL *string `json:"previous_attempt_url,omitempty"`
44+
HeadCommit *HeadCommit `json:"head_commit,omitempty"`
45+
WorkflowURL *string `json:"workflow_url,omitempty"`
46+
Repository *Repository `json:"repository,omitempty"`
47+
HeadRepository *Repository `json:"head_repository,omitempty"`
48+
Actor *User `json:"actor,omitempty"`
49+
TriggeringActor *User `json:"triggering_actor,omitempty"`
50+
ReferencedWorkflows []*ReferencedWorkflow `json:"referenced_workflows,omitempty"`
5051
}
5152

5253
// WorkflowRuns represents a slice of repository action workflow run.
@@ -104,6 +105,12 @@ type PendingDeploymentsRequest struct {
104105
Comment string `json:"comment"`
105106
}
106107

108+
type ReferencedWorkflow struct {
109+
Path *string `json:"path,omitempty"`
110+
SHA *string `json:"sha,omitempty"`
111+
Ref *string `json:"ref,omitempty"`
112+
}
113+
107114
func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
108115
u, err := addOptions(endpoint, opts)
109116
if err != nil {

github/actions_workflow_runs_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,13 @@ func TestWorkflowRun_Marshal(t *testing.T) {
761761
SuspendedAt: &Timestamp{referenceTime},
762762
URL: String("u2"),
763763
},
764+
ReferencedWorkflows: []*ReferencedWorkflow{
765+
{
766+
Path: String("rwfp"),
767+
SHA: String("rwfsha"),
768+
Ref: String("rwfref"),
769+
},
770+
},
764771
}
765772

766773
want := `{
@@ -881,7 +888,14 @@ func TestWorkflowRun_Marshal(t *testing.T) {
881888
"created_at": ` + referenceTimeStr + `,
882889
"suspended_at": ` + referenceTimeStr + `,
883890
"url": "u2"
884-
}
891+
},
892+
"referenced_workflows": [
893+
{
894+
"path": "rwfp",
895+
"sha": "rwfsha",
896+
"ref": "rwfref"
897+
}
898+
]
885899
}`
886900

887901
testJSONMarshal(t, u, want)

github/github-accessors.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)