Skip to content

Commit 6de531e

Browse files
authored
Create delete_old_workflow_runs.yml
1 parent 3f0b9f5 commit 6de531e

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Delete old workflow runs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
days:
6+
description: 'Days-worth of runs to keep for each workflow'
7+
required: true
8+
default: '7' # default value is "30"
9+
minimum_runs:
10+
description: 'Minimum runs to keep for each workflow'
11+
required: true
12+
default: '5' # default value is "6"
13+
delete_workflow_pattern:
14+
description: 'Name or filename of the workflow (if not set, all workflows are targeted)'
15+
required: false
16+
default: ''
17+
delete_workflow_by_state_pattern:
18+
description: 'Filter workflows by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
19+
required: true
20+
default: "ALL"
21+
type: choice
22+
options:
23+
- "ALL"
24+
- active
25+
- deleted
26+
- disabled_inactivity
27+
- disabled_manually
28+
delete_run_by_conclusion_pattern:
29+
description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success'
30+
required: true
31+
default: "ALL"
32+
type: choice
33+
options:
34+
- "ALL"
35+
- "Unsuccessful: action_required,cancelled,failure,skipped"
36+
- action_required
37+
- cancelled
38+
- failure
39+
- skipped
40+
- success
41+
dry_run:
42+
description: 'Logs simulated changes, no deletions are performed'
43+
required: false
44+
45+
jobs:
46+
del_runs:
47+
runs-on: ubuntu-latest
48+
permissions:
49+
actions: write
50+
contents: read
51+
steps:
52+
- name: Delete workflow runs
53+
uses: Mattraks/delete-workflow-runs@v2
54+
with:
55+
token: ${{ github.token }}
56+
repository: ${{ github.repository }}
57+
retain_days: ${{ github.event.inputs.days }}
58+
keep_minimum_runs: ${{ github.event.inputs.minimum_runs }}
59+
delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }}
60+
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }}
61+
delete_run_by_conclusion_pattern: >-
62+
${{
63+
startsWith(github.event.inputs.delete_run_by_conclusion_pattern, 'Unsuccessful:')
64+
&& 'action_required,cancelled,failure,skipped'
65+
|| github.event.inputs.delete_run_by_conclusion_pattern
66+
}}
67+
dry_run: ${{ github.event.inputs.dry_run }}

0 commit comments

Comments
 (0)