Skip to content

Commit 295b73b

Browse files
committed
cleanup workflow: fix skip current workflow
1 parent 7b071b9 commit 295b73b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

.github/workflows/cleanup.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
script: |
1717
const KEEP = 0;
1818
const workflowNames = ["VirusTotal Scan", "Cleanup old workflow runs"];
19-
const currentWorkflowName = context.workflow;
2019
2120
// Get workflow ID
2221
const workflows = await github.rest.actions.listRepoWorkflows({
@@ -31,11 +30,6 @@ jobs:
3130
continue;
3231
}
3332
34-
if (wf.name === currentWorkflowName) {
35-
core.info(`Skipping current workflow "${wf.name}"`);
36-
continue;
37-
}
38-
3933
// List runs
4034
const runs = await github.rest.actions.listWorkflowRuns({
4135
owner: context.repo.owner,
@@ -48,11 +42,15 @@ jobs:
4842
core.info(`Deleting ${toDelete.length} old runs`);
4943
5044
for (const run of toDelete) {
51-
await github.rest.actions.deleteWorkflowRun({
52-
owner: context.repo.owner,
53-
repo: context.repo.repo,
54-
run_id: run.id
55-
});
45+
try {
46+
await github.rest.actions.deleteWorkflowRun({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
run_id: run.id
50+
});
51+
} catch (e) {
52+
core.info(`Skip run ${run.id}: ${e.message}`);
53+
}
5654
}
5755
}
5856

0 commit comments

Comments
 (0)