Skip to content

Commit 97652c6

Browse files
committed
Expose repository for artifacts, workflows and workflow runs
1 parent f40daf8 commit 97652c6

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ public Date getExpiresAt() {
7373
return GitHubClient.parseDate(expiresAt);
7474
}
7575

76+
/**
77+
* Repository to which the artifact belongs.
78+
*
79+
* @return the repository
80+
*/
81+
public GHRepository getRepository() {
82+
return owner;
83+
}
84+
7685
/**
7786
* @deprecated This object has no HTML URL.
7887
*/

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public URL getHtmlUrl() throws IOException {
6060
return GitHubClient.parseURL(htmlUrl);
6161
}
6262

63+
/**
64+
* Repository to which the workflow belongs.
65+
*
66+
* @return the repository
67+
*/
68+
public GHRepository getRepository() {
69+
return owner;
70+
}
71+
6372
/**
6473
* The badge URL, like https://github.com/octo-org/octo-repo/workflows/CI/badge.svg
6574
*

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ public Conclusion getConclusion() {
213213
return Conclusion.from(conclusion);
214214
}
215215

216+
/**
217+
* Repository to which the workflow run belongs.
218+
*
219+
* @return the repository
220+
*/
221+
public GHRepository getRepository() {
222+
return owner;
223+
}
224+
216225
/**
217226
* Gets the pull requests participated in this workflow run.
218227
*

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public void testManualRunAndBasicInformation() throws IOException {
6262
() -> new IllegalStateException("We must have a valid workflow run starting from here"));
6363

6464
assertEquals(workflow.getId(), workflowRun.getWorkflowId());
65+
assertNotNull(workflowRun.getId());
66+
assertNotNull(workflowRun.getNodeId());
67+
assertEquals(REPO_NAME, workflowRun.getRepository().getFullName());
6568
assertTrue(workflowRun.getUrl().getPath().contains("/actions/runs/"));
6669
assertTrue(workflowRun.getHtmlUrl().getPath().contains("/actions/runs/"));
6770
assertTrue(workflowRun.getJobsUrl().getPath().endsWith("/jobs"));
@@ -379,6 +382,7 @@ private static Status getWorkflowRunStatus(GHRepository repository, long workflo
379382
private static void checkArtifactProperties(GHArtifact artifact, String artifactName) throws IOException {
380383
assertNotNull(artifact.getId());
381384
assertNotNull(artifact.getNodeId());
385+
assertEquals(REPO_NAME, artifact.getRepository().getFullName());
382386
assertThat(artifact.getName(), is(artifactName));
383387
assertThat(artifact.getArchiveDownloadUrl().getPath(), containsString("actions/artifacts"));
384388
assertNotNull(artifact.getCreatedAt());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void testBasicInformation() throws IOException {
4343
GHWorkflow workflow = repo.getWorkflow("test-workflow.yml");
4444

4545
assertEquals("test-workflow", workflow.getName());
46+
assertEquals(REPO_NAME, workflow.getRepository().getFullName());
4647
assertEquals(".github/workflows/test-workflow.yml", workflow.getPath());
4748
assertEquals("active", workflow.getState());
4849
assertEquals("/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859", workflow.getUrl().getPath());

0 commit comments

Comments
 (0)