Skip to content

Commit 8714d1b

Browse files
authored
Include triggering actor in workflow run (hub4j#2006)
1 parent c8f4815 commit 8714d1b

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public GHWorkflowRun() {
4242

4343
private long runAttempt;
4444
private String runStartedAt;
45+
private GHUser triggeringActor;
4546

4647
private String htmlUrl;
4748
private String jobsUrl;
@@ -119,6 +120,16 @@ public Date getRunStartedAt() throws IOException {
119120
return GitHubClient.parseDate(runStartedAt);
120121
}
121122

123+
/**
124+
* The actor which triggered the run.
125+
*
126+
* @return the triggering actor
127+
*/
128+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
129+
public GHUser getTriggeringActor() {
130+
return triggeringActor;
131+
}
132+
122133
/**
123134
* Gets the html url.
124135
*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public void testManualRunAndBasicInformation() throws IOException {
117117
assertThat(workflowRun.getStatus(), equalTo(Status.COMPLETED));
118118
assertThat(workflowRun.getConclusion(), equalTo(Conclusion.SUCCESS));
119119
assertThat(workflowRun.getHeadSha(), notNullValue());
120+
assertThat(workflowRun.getTriggeringActor(), hasProperty("login", equalTo("octocat")));
120121
}
121122

122123
/**

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@
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": {
30+
"login": "octocat",
31+
"id": 1,
32+
"node_id": "MDQ6VXNlcjE=",
33+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
34+
"gravatar_id": "",
35+
"url": "https://api.github.com/users/octocat",
36+
"html_url": "https://github.com/octocat",
37+
"followers_url": "https://api.github.com/users/octocat/followers",
38+
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
39+
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
40+
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
41+
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
42+
"organizations_url": "https://api.github.com/users/octocat/orgs",
43+
"repos_url": "https://api.github.com/users/octocat/repos",
44+
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
45+
"received_events_url": "https://api.github.com/users/octocat/received_events",
46+
"type": "User",
47+
"site_admin": false
48+
},
2949
"head_commit": {
3050
"id": "f6a5c19a67797d64426203b8a7a05a0fd74e5037",
3151
"tree_id": "666bb9f951306171acb21632eca28a386cb35f73",

0 commit comments

Comments
 (0)