Skip to content

Commit

Permalink
Merge pull request #35 from joutvhu/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
joutvhu authored Jan 20, 2024
2 parents 3eeaa16 + 3189247 commit b65216e
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 74 deletions.
35 changes: 0 additions & 35 deletions action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120702,13 +120702,11 @@ const io_helper_1 = __nccwpck_require__(3262);
yield Promise.all(artifactsToDelete.map((value) => __awaiter(this, void 0, void 0, function* () {
try {
yield artifact_1.default.deleteArtifact(value.name, findOptions);
core.info(`Artifact ${value.name} was deleted`);
result.artifacts[value.name] = Object.assign(Object.assign({}, value), { status: 'success' });
result.deleted.count++;
result.deleted.names.push(value.name);
}
catch (e) {
core.info(`Deleting artifact ${value.name} failed`);
result.artifacts[value.name] = Object.assign(Object.assign({}, value), { status: 'fail' });
result.failed.count++;
result.failed.names.push(value.name);
Expand Down Expand Up @@ -120758,46 +120756,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setOutputs = exports.getInputs = exports.getBooleanInput = exports.isNotBlank = exports.DeleteInputs = void 0;
const core = __importStar(__nccwpck_require__(2186));
const constants_1 = __nccwpck_require__(9042);
const github_1 = __nccwpck_require__(5438);
class DeleteInputs {
constructor(artifactNames = []) {
this.artifactNames = artifactNames;
}
get deleteAll() {
return this.artifactNames == null || this.artifactNames.length === 0;
}
get findOptions() {
var _a, _b;
const options = {};
if (isNotBlank(this.runId) && isNotBlank(this.token)) {
options.findBy = {
token: this.token,
repositoryOwner: (_a = this.owner) !== null && _a !== void 0 ? _a : github_1.context.repo.owner,
repositoryName: (_b = this.repo) !== null && _b !== void 0 ? _b : github_1.context.repo.repo,
workflowRunId: this.runId
};
}
if (this.latest != null) {
options.latest = this.latest;
}
return options;
}
get listOptions() {
var _a, _b;
const options = {};
if (isNotBlank(this.runId) && isNotBlank(this.token)) {
options.findBy = {
token: this.token,
repositoryOwner: (_a = this.owner) !== null && _a !== void 0 ? _a : github_1.context.repo.owner,
repositoryName: (_b = this.repo) !== null && _b !== void 0 ? _b : github_1.context.repo.repo,
workflowRunId: this.runId
};
}
if (this.latest != null) {
options.latest = this.latest;
}
return options;
}
}
exports.DeleteInputs = DeleteInputs;
function isNotBlank(value) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "delete-artifact",
"version": "2.0.0",
"version": "2.0.1",
"description": "Delete a build artifact that was previously uploaded in the workflow by the upload-artifact action",
"scripts": {
"build": "npm run clean && tsc --project tsconfig.json",
Expand Down
2 changes: 0 additions & 2 deletions src/delete-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ export interface DeleteResponse {
await Promise.all(artifactsToDelete.map(async (value) => {
try {
await artifact.deleteArtifact(value.name, findOptions);
core.info(`Artifact ${value.name} was deleted`);
result.artifacts[value.name] = {
...value,
status: 'success'
};
result.deleted.count++;
result.deleted.names.push(value.name);
} catch (e) {
core.info(`Deleting artifact ${value.name} failed`);
result.artifacts[value.name] = {
...value,
status: 'fail'
Expand Down
34 changes: 0 additions & 34 deletions src/io-helper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as core from '@actions/core';
import {InputOptions} from '@actions/core';
import {Inputs, Outputs} from './constants';
import {FindOptions, ListArtifactsOptions} from '@actions/artifact';
import {context} from '@actions/github';

export class DeleteInputs {
public owner?: string;
Expand All @@ -23,38 +21,6 @@ export class DeleteInputs {
public get deleteAll(): boolean {
return this.artifactNames == null || this.artifactNames.length === 0;
}

public get findOptions(): FindOptions {
const options: ListArtifactsOptions & FindOptions = {};
if (isNotBlank(this.runId) && isNotBlank(this.token)) {
options.findBy = {
token: this.token as string,
repositoryOwner: this.owner ?? context.repo.owner,
repositoryName: this.repo ?? context.repo.repo,
workflowRunId: this.runId as number
};
}
if (this.latest != null) {
options.latest = this.latest;
}
return options;
}

public get listOptions(): ListArtifactsOptions & FindOptions {
const options: ListArtifactsOptions & FindOptions = {};
if (isNotBlank(this.runId) && isNotBlank(this.token)) {
options.findBy = {
token: this.token as string,
repositoryOwner: this.owner ?? context.repo.owner,
repositoryName: this.repo ?? context.repo.repo,
workflowRunId: this.runId as number
};
}
if (this.latest != null) {
options.latest = this.latest;
}
return options;
}
}

export function isNotBlank(value: any): boolean {
Expand Down

0 comments on commit b65216e

Please sign in to comment.