Skip to content

Commit 8422e75

Browse files
authored
Add workflow to delete old workflow runs
1 parent 3779597 commit 8422e75

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

.github/workflows/delete.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Delete old workflow runs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
days:
6+
description: "Days to retain runs"
7+
default: "30"
8+
minimum_runs:
9+
description: "Minimum runs to keep"
10+
default: "6"
11+
use_daily_retention:
12+
description: "Enable daily retention (keep minimum runs per day instead of overall)"
13+
default: "false"
14+
type: choice
15+
options:
16+
- "false"
17+
- "true"
18+
delete_workflow_pattern:
19+
description: "Workflow name or filename (omit for all). Use `|` to separate multiple filters (e.g. 'build|deploy')."
20+
delete_workflow_by_state_pattern:
21+
description: "Workflow state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually"
22+
default: "ALL"
23+
type: choice
24+
options:
25+
- "ALL"
26+
- active
27+
- deleted
28+
- disabled_inactivity
29+
- disabled_manually
30+
delete_run_by_conclusion_pattern:
31+
description: "Run conclusion: action_required, cancelled, failure, skipped, success"
32+
default: "ALL"
33+
type: choice
34+
options:
35+
- "ALL"
36+
- "Unsuccessful: action_required,cancelled,failure,skipped"
37+
- action_required
38+
- cancelled
39+
- failure
40+
- skipped
41+
- success
42+
dry_run:
43+
description: "Simulate deletions"
44+
default: "false"
45+
type: choice
46+
options:
47+
- "false"
48+
- "true"
49+
jobs:
50+
delete-runs:
51+
runs-on: ubuntu-latest
52+
permissions:
53+
actions: write
54+
contents: read
55+
steps:
56+
- name: Delete workflow runs
57+
uses: Mattraks/delete-workflow-runs@v2
58+
with:
59+
token: ${{ github.token }}
60+
repository: ${{ github.repository }}
61+
retain_days: ${{ github.event.inputs.days }}
62+
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
63+
use_daily_retention: ${{ github.event.inputs.use_daily_retention }}
64+
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
65+
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
66+
delete_run_by_conclusion_pattern: >-
67+
${{
68+
startsWith(github.event.inputs.delete_run_by_conclusion_pattern, 'Unsuccessful:') &&
69+
'action_required,cancelled,failure,skipped' ||
70+
github.event.inputs.delete_run_by_conclusion_pattern
71+
}}
72+
dry_run: ${{ github.event.inputs.dry_run }}

0 commit comments

Comments
 (0)