Skip to content

Delete old workflow runs #381

Delete old workflow runs

Delete old workflow runs #381

---
# yamllint disable rule:line-length
name: Delete old workflow runs
on: # yamllint disable-line rule:truthy
schedule:
- cron: '9 0 * * *'
workflow_dispatch:
inputs:
days:
description: 'Number of days.'
required: true
default: 30
minimum_runs:
description: 'The minimum runs to keep for each workflow.'
required: true
default: 6
delete_workflow_by_state_pattern:
description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
required: true
default: "All"
type: choice
options:
- "All"
- active
- deleted
- disabled_inactivity
- disabled_manually
delete_run_by_conclusion_pattern:
description: 'Remove workflow by conclusion: action_required, cancelled, failure, skipped, success'
required: true
default: "All"
type: choice
options:
- "All"
- action_required
- cancelled
- failure
- skipped
- success
jobs:
del_runs:
runs-on:
- self-hosted
timeout-minutes: 10
permissions:
actions: write
contents: write
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: ${{ github.event.inputs.days || 7 }}
keep_minimum_runs: ${{ github.event.inputs.minimum_runs || 3 }}
delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern || 'All' }}
delete_run_by_conclusion_pattern: ${{ github.event.inputs.delete_run_by_conclusion_pattern || 'All' }}