File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
src/main/java/org/kohsuke/github Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,16 @@ public PagedIterable<GHWorkflowRun> listRuns() {
156
156
return new GHWorkflowRunsIterable (owner , root ().createRequest ().withUrlPath (getApiRoute (), "runs" ));
157
157
}
158
158
159
+ /**
160
+ * Workflow run query builder for this workflow.
161
+ *
162
+ * @return the GHWorkflowRunQueryBuilder instance for querying runs
163
+ */
164
+ public GHWorkflowRunQueryBuilder queryRuns () {
165
+ return new GHWorkflowRunQueryBuilder (this );
166
+
167
+ }
168
+
159
169
private String getApiRoute () {
160
170
if (owner == null ) {
161
171
// Workflow runs returned from search to do not have an owner. Attempt to use url.
Original file line number Diff line number Diff line change 11
11
* @see GHRepository#queryWorkflowRuns()
12
12
*/
13
13
public class GHWorkflowRunQueryBuilder extends GHQueryBuilder <GHWorkflowRun > {
14
+ private final GHWorkflow ghWorkflow ;
14
15
private final GHRepository repo ;
15
16
16
17
/**
@@ -22,6 +23,19 @@ public class GHWorkflowRunQueryBuilder extends GHQueryBuilder<GHWorkflowRun> {
22
23
GHWorkflowRunQueryBuilder (GHRepository repo ) {
23
24
super (repo .root ());
24
25
this .repo = repo ;
26
+ this .ghWorkflow = null ;
27
+ }
28
+
29
+ /**
30
+ * Instantiates a new GH workflow run query builder for a specific workflow.
31
+ *
32
+ * @param ghWorkflow
33
+ * the ghWorkflow
34
+ */
35
+ GHWorkflowRunQueryBuilder (GHWorkflow ghWorkflow ) {
36
+ super (ghWorkflow .getRepository ().root ());
37
+ this .repo = ghWorkflow .getRepository ();
38
+ this .ghWorkflow = ghWorkflow ;
25
39
}
26
40
27
41
/**
@@ -133,7 +147,12 @@ public GHWorkflowRunQueryBuilder headSha(String headSha) {
133
147
*/
134
148
@ Override
135
149
public PagedIterable <GHWorkflowRun > list () {
136
- return new GHWorkflowRunsIterable (repo , req .withUrlPath (repo .getApiTailUrl ("actions/runs" )));
150
+ if (ghWorkflow != null ) {
151
+ req .withUrlPath (repo .getApiTailUrl ("actions/workflows" ), String .valueOf (ghWorkflow .getId ()), "runs" );
152
+ } else {
153
+ req .withUrlPath (repo .getApiTailUrl ("actions/runs" ));
154
+ }
155
+ return new GHWorkflowRunsIterable (repo , req );
137
156
}
138
157
139
158
/**
You can’t perform that action at this time.
0 commit comments