Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove skip-tag option #7

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ inputs:
GITHUB_TOKEN:
description: 'Access token for the repository, available under the same name in secrets.'
required: true
skip-tags:
description: 'If enabled, tag build artifacts (e.g. release artifacts) will be kept.'
required: false
53 changes: 13 additions & 40 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ async function run() {
")"
);

const skipTags = core.getInput("skip-tags");
if (skipTags) console.log("Skipping tags");

const repoOptions = { owner, repo };

const workflowRunsRequest = octokit.actions.listRepoWorkflowRuns.endpoint.merge(
Expand All @@ -45,44 +42,20 @@ async function run() {
const createdAt = moment(artifact.created_at);

if (createdAt.isBefore(maxAge)) {
let shouldDelete = true;

if (skipTags) {
console.log("Looking for tag on sha", workflowRun.head_sha);
try {
const { data: tag } = await octokit.git.getTag({
owner,
repo,
tag_sha: workflowRun.head_sha,
});
if (tag) {
shouldDelete = false;
}
console.log(tag);
} catch (error) {
if (error.status !== 404) {
throw error;
}
console.log("Tag not found for", workflowRun.head_sha);
}
}

if (shouldDelete) {
console.log(
"Deleting Artifact which was created",
createdAt.from(maxAge),
"from maximum age for Workflow Run",
workflowRun.id,
": ",
artifact
);
console.log(
"Deleting Artifact which was created",
createdAt.from(maxAge),
"from maximum age for Workflow Run",
workflowRun.id,
": ",
artifact
);

await octokit.actions.deleteArtifact({
owner,
repo,
artifact_id: artifact.id,
});
}
await octokit.actions.deleteArtifact({
owner,
repo,
artifact_id: artifact.id,
});
}
}
}
Expand Down