Skip to content

Commit 14e1d62

Browse files
committed
Add actor to GHWorkflowRun
1 parent 362faaf commit 14e1d62

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/main/java/org/kohsuke/github/GHWorkflowRun.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public String toString() {
207207
return name().toLowerCase(Locale.ROOT);
208208
}
209209
}
210+
private GHUser actor;
210211
private String artifactsUrl;
211212
private String cancelUrl;
212213
private String checkSuiteUrl;
@@ -307,6 +308,16 @@ public <T> T downloadLogs(InputStreamFunction<T> streamFunction) throws IOExcept
307308
return root().createRequest().method("GET").withUrlPath(getApiRoute(), "logs").fetchStream(streamFunction);
308309
}
309310

311+
/**
312+
* The actor which triggered the initial run.
313+
*
314+
* @return the triggering actor
315+
*/
316+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
317+
public GHUser getActor() {
318+
return actor;
319+
}
320+
310321
/**
311322
* The artifacts URL, like https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/artifacts
312323
*

src/test/java/org/kohsuke/github/GHWorkflowRunTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ public void testManualRunAndBasicInformation() throws IOException {
604604
assertThat(workflowRun.getStatus(), equalTo(Status.COMPLETED));
605605
assertThat(workflowRun.getConclusion(), equalTo(Conclusion.SUCCESS));
606606
assertThat(workflowRun.getHeadSha(), notNullValue());
607-
assertThat(workflowRun.getTriggeringActor(), hasProperty("login", equalTo("octocat")));
607+
assertThat(workflowRun.getActor(), hasProperty("login", equalTo("octocat")));
608+
assertThat(workflowRun.getTriggeringActor(), hasProperty("login", equalTo("octocat_trigger")));
608609
}
609610

610611
/**

src/test/resources/org/kohsuke/github/GHWorkflowRunTest/wiremock/testManualRunAndBasicInformation/__files/6-r_h_g_actions_runs.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"cancel_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686034992/cancel",
2727
"rerun_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686034992/rerun",
2828
"workflow_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/workflows/6820790",
29-
"triggering_actor": {
29+
"actor": {
3030
"login": "octocat",
3131
"id": 1,
3232
"node_id": "MDQ6VXNlcjE=",
@@ -46,6 +46,26 @@
4646
"type": "User",
4747
"site_admin": false
4848
},
49+
"triggering_actor": {
50+
"login": "octocat_trigger",
51+
"id": 1,
52+
"node_id": "MDQ6VXNlcjE=",
53+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
54+
"gravatar_id": "",
55+
"url": "https://api.github.com/users/octocat_trigger",
56+
"html_url": "https://github.com/octocat_trigger",
57+
"followers_url": "https://api.github.com/users/octocat_trigger/followers",
58+
"following_url": "https://api.github.com/users/octocat_trigger/following{/other_user}",
59+
"gists_url": "https://api.github.com/users/octocat_trigger/gists{/gist_id}",
60+
"starred_url": "https://api.github.com/users/octocat_trigger/starred{/owner}{/repo}",
61+
"subscriptions_url": "https://api.github.com/users/octocat_trigger/subscriptions",
62+
"organizations_url": "https://api.github.com/users/octocat_trigger/orgs",
63+
"repos_url": "https://api.github.com/users/octocat_trigger/repos",
64+
"events_url": "https://api.github.com/users/octocat_trigger/events{/privacy}",
65+
"received_events_url": "https://api.github.com/users/octocat_trigger/received_events",
66+
"type": "User",
67+
"site_admin": false
68+
},
4969
"head_commit": {
5070
"id": "f6a5c19a67797d64426203b8a7a05a0fd74e5037",
5171
"tree_id": "666bb9f951306171acb21632eca28a386cb35f73",

0 commit comments

Comments
 (0)