Skip to content

Commit 9d15d16

Browse files
committed
refactor: update repo selection
1 parent 94e3ae5 commit 9d15d16

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

LICENSE

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Richard Herman
3+
Copyright (c) Richard Herman
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22+

dist/index.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -29236,7 +29236,6 @@ class ArtifactClient {
2923629236
*/
2923729237
constructor(token) {
2923829238
this.octokit = github.getOctokit(token);
29239-
[this.owner, this.repo] = process.env.GITHUB_REPOSITORY.split("/");
2924029239
}
2924129240
/**
2924229241
* Deletes the specified artifact.
@@ -29245,11 +29244,7 @@ class ArtifactClient {
2924529244
*/
2924629245
del(artifactId) {
2924729246
return __awaiter(this, void 0, void 0, function* () {
29248-
const { status } = yield this.octokit.rest.actions.deleteArtifact({
29249-
artifact_id: artifactId,
29250-
owner: this.owner,
29251-
repo: this.repo,
29252-
});
29247+
const { status } = yield this.octokit.rest.actions.deleteArtifact(Object.assign(Object.assign({}, github.context.repo), { artifact_id: artifactId }));
2925329248
return this.success(status);
2925429249
});
2925529250
}
@@ -29259,11 +29254,7 @@ class ArtifactClient {
2925929254
*/
2926029255
list() {
2926129256
return __awaiter(this, void 0, void 0, function* () {
29262-
const res = yield this.octokit.rest.actions.listWorkflowRunArtifacts({
29263-
owner: this.owner,
29264-
repo: this.repo,
29265-
run_id: parseInt(process.env.GITHUB_RUN_ID),
29266-
});
29257+
const res = yield this.octokit.rest.actions.listWorkflowRunArtifacts(Object.assign(Object.assign({}, github.context.repo), { run_id: parseInt(process.env.GITHUB_RUN_ID) }));
2926729258
if (!this.success(res.status)) {
2926829259
throw new Error("Failed to load artifacts");
2926929260
}

src/artifact-client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,12 @@ export class ArtifactClient {
1010
*/
1111
private readonly octokit: ReturnType<typeof github.getOctokit>;
1212

13-
/**
14-
* Owner of the GitHub repository.
15-
*/
16-
private readonly owner: string;
17-
18-
/**
19-
* GitHub repository.
20-
*/
21-
private readonly repo: string;
22-
2313
/**
2414
* Initializes a new instance of the {@link ArtifactClient}.
2515
* @param token GitHub token with read and write access to actions.
2616
*/
2717
constructor(token: string) {
2818
this.octokit = github.getOctokit(token);
29-
[this.owner, this.repo] = process.env.GITHUB_REPOSITORY.split("/");
3019
}
3120

3221
/**
@@ -36,9 +25,8 @@ export class ArtifactClient {
3625
*/
3726
public async del(artifactId: number): Promise<boolean> {
3827
const { status } = await this.octokit.rest.actions.deleteArtifact({
28+
...github.context.repo,
3929
artifact_id: artifactId,
40-
owner: this.owner,
41-
repo: this.repo,
4230
});
4331

4432
return this.success(status);
@@ -50,8 +38,7 @@ export class ArtifactClient {
5038
*/
5139
public async list(): Promise<Artifact[]> {
5240
const res = await this.octokit.rest.actions.listWorkflowRunArtifacts({
53-
owner: this.owner,
54-
repo: this.repo,
41+
...github.context.repo,
5542
run_id: parseInt(process.env.GITHUB_RUN_ID),
5643
});
5744

@@ -73,4 +60,3 @@ export class ArtifactClient {
7360
);
7461
}
7562
}
76-

0 commit comments

Comments
 (0)