clean-up.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Workflow that cleans up outdated and old workflows to prevent out of disk issues
  2. name: Delete old workflow runs
  3. # This workflow is currently only triggered manually
  4. on:
  5. workflow_dispatch:
  6. inputs:
  7. days:
  8. description: 'Days-worth of runs to keep for each workflow'
  9. required: true
  10. default: '30'
  11. minimum_runs:
  12. description: 'Minimum runs to keep for each workflow'
  13. required: true
  14. default: '10'
  15. delete_workflow_pattern:
  16. description: 'Name or filename of the workflow (if not set, all workflows are targeted)'
  17. required: false
  18. delete_workflow_by_state_pattern:
  19. description: 'Filter workflows by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually'
  20. required: true
  21. default: "ALL"
  22. type: choice
  23. options:
  24. - "ALL"
  25. - active
  26. - deleted
  27. - disabled_inactivity
  28. - disabled_manually
  29. delete_run_by_conclusion_pattern:
  30. description: 'Remove runs based on conclusion: action_required, cancelled, failure, skipped, success'
  31. required: true
  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: 'Logs simulated changes, no deletions are performed'
  44. required: false
  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 }}