-
-
Notifications
You must be signed in to change notification settings - Fork 179
42 lines (40 loc) · 1.3 KB
/
Copy pathremove.yml
File metadata and controls
42 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Remove Skipped Workflow Runs
on:
workflow_dispatch:
jobs:
remove-skipped-runs:
runs-on: ubuntu-slim
permissions:
actions: write
steps:
- name: Remove Skipped Workflow Runs
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const runs = await github.paginate(
github.rest.actions.listWorkflowRunsForRepo,
{
owner: context.repo.owner,
repo: context.repo.repo,
status: "skipped",
per_page: 100,
},
);
let deletedCount = 0;
let failedCount = 0;
for (const run of runs) {
try {
await github.rest.actions.deleteWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id,
});
deletedCount++;
} catch (error) {
console.error(`Error deleting workflow run: ${error.message}`);
failedCount++;
}
}
console.log(`Deleted skipped workflow runs: ${deletedCount}`);
console.log(`Failed to delete workflow runs: ${failedCount}`);