Skip to content

Commit

Permalink
refactor: update repo selection
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekyEggo committed Dec 24, 2023
1 parent 94e3ae5 commit 9d15d16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.

13 changes: 2 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
});
}
Expand All @@ -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");
}
Expand Down
18 changes: 2 additions & 16 deletions src/artifact-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,12 @@ export class ArtifactClient {
*/
private readonly octokit: ReturnType<typeof github.getOctokit>;

/**
* 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("/");
}

/**
Expand All @@ -36,9 +25,8 @@ export class ArtifactClient {
*/
public async del(artifactId: number): Promise<boolean> {
const { status } = await this.octokit.rest.actions.deleteArtifact({
...github.context.repo,
artifact_id: artifactId,
owner: this.owner,
repo: this.repo,
});

return this.success(status);
Expand All @@ -50,8 +38,7 @@ export class ArtifactClient {
*/
public async list(): Promise<Artifact[]> {
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),
});

Expand All @@ -73,4 +60,3 @@ export class ArtifactClient {
);
}
}

0 comments on commit 9d15d16

Please sign in to comment.