diff --git a/LICENSE b/LICENSE index 49a30f3..469aea9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Richard Herman +Copyright (c) Richard Herman Permission is hereby granted, free of charge, to any person obtaining a copy 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 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/dist/index.js b/dist/index.js index 135c68e..f70a6f6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29236,7 +29236,6 @@ class ArtifactClient { */ constructor(token) { this.octokit = github.getOctokit(token); - [this.owner, this.repo] = process.env.GITHUB_REPOSITORY.split("/"); } /** * Deletes the specified artifact. @@ -29245,11 +29244,7 @@ class ArtifactClient { */ del(artifactId) { return __awaiter(this, void 0, void 0, function* () { - const { status } = yield this.octokit.rest.actions.deleteArtifact({ - artifact_id: artifactId, - owner: this.owner, - repo: this.repo, - }); + const { status } = yield this.octokit.rest.actions.deleteArtifact(Object.assign(Object.assign({}, github.context.repo), { artifact_id: artifactId })); return this.success(status); }); } @@ -29259,11 +29254,7 @@ class ArtifactClient { */ list() { return __awaiter(this, void 0, void 0, function* () { - const res = yield this.octokit.rest.actions.listWorkflowRunArtifacts({ - owner: this.owner, - repo: this.repo, - run_id: parseInt(process.env.GITHUB_RUN_ID), - }); + const res = yield this.octokit.rest.actions.listWorkflowRunArtifacts(Object.assign(Object.assign({}, github.context.repo), { run_id: parseInt(process.env.GITHUB_RUN_ID) })); if (!this.success(res.status)) { throw new Error("Failed to load artifacts"); } diff --git a/src/artifact-client.ts b/src/artifact-client.ts index 03cc00b..cca047c 100644 --- a/src/artifact-client.ts +++ b/src/artifact-client.ts @@ -10,23 +10,12 @@ export class ArtifactClient { */ private readonly octokit: ReturnType; - /** - * Owner of the GitHub repository. - */ - private readonly owner: string; - - /** - * GitHub repository. - */ - private readonly repo: string; - /** * Initializes a new instance of the {@link ArtifactClient}. * @param token GitHub token with read and write access to actions. */ constructor(token: string) { this.octokit = github.getOctokit(token); - [this.owner, this.repo] = process.env.GITHUB_REPOSITORY.split("/"); } /** @@ -36,9 +25,8 @@ export class ArtifactClient { */ public async del(artifactId: number): Promise { const { status } = await this.octokit.rest.actions.deleteArtifact({ + ...github.context.repo, artifact_id: artifactId, - owner: this.owner, - repo: this.repo, }); return this.success(status); @@ -50,8 +38,7 @@ export class ArtifactClient { */ public async list(): Promise { const res = await this.octokit.rest.actions.listWorkflowRunArtifacts({ - owner: this.owner, - repo: this.repo, + ...github.context.repo, run_id: parseInt(process.env.GITHUB_RUN_ID), }); @@ -73,4 +60,3 @@ export class ArtifactClient { ); } } -