Skip to content

Commit 7847cf4

Browse files
committed
upd cleanup old workflows
1 parent 6b4e076 commit 7847cf4

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

.github/workflows/cleanup.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,38 @@ jobs:
1515
with:
1616
script: |
1717
const KEEP = 10;
18-
const workflowName = "Build Debug APK";
18+
const workflowNames = ["Build Debug APK", "VirusTotal Scan"];
1919
2020
// Get workflow ID
2121
const workflows = await github.rest.actions.listRepoWorkflows({
2222
owner: context.repo.owner,
2323
repo: context.repo.repo
2424
});
25-
const wf = workflows.data.workflows.find(w => w.name === workflowName);
26-
if (!wf) {
27-
core.setFailed("Workflow not found");
28-
return;
29-
}
30-
31-
// List runs
32-
const runs = await github.rest.actions.listWorkflowRuns({
33-
owner: context.repo.owner,
34-
repo: context.repo.repo,
35-
workflow_id: wf.id,
36-
per_page: 100
37-
});
3825
39-
const toDelete = runs.data.workflow_runs.slice(KEEP);
40-
core.info(`Deleting ${toDelete.length} old runs`);
26+
for (const name of workflowNames) {
27+
const wf = workflows.data.workflows.find(w => w.name === name);
28+
if (!wf) {
29+
core.info(`Workflow "${name}" not found, skipping`);
30+
continue;
31+
}
4132
42-
for (const run of toDelete) {
43-
await github.rest.actions.deleteWorkflowRun({
33+
// List runs
34+
const runs = await github.rest.actions.listWorkflowRuns({
4435
owner: context.repo.owner,
4536
repo: context.repo.repo,
46-
run_id: run.id
37+
workflow_id: wf.id,
38+
per_page: 100
4739
});
40+
41+
const toDelete = runs.data.workflow_runs.slice(KEEP);
42+
core.info(`Deleting ${toDelete.length} old runs`);
43+
44+
for (const run of toDelete) {
45+
await github.rest.actions.deleteWorkflowRun({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
run_id: run.id
49+
});
50+
}
4851
}
52+

0 commit comments

Comments
 (0)