Skip to content

cleanup-workflow-runs #378

cleanup-workflow-runs

cleanup-workflow-runs #378

name: cleanup-workflow-runs
on:
schedule:
- cron: "0 0 * * *" # GMT
workflow_dispatch:
inputs:
days_to_keep:
description: 'Number of days to keep workflow runs'
required: false
default: '5'
type: string
delete_cancelled:
description: 'Delete cancelled workflow runs'
required: false
default: true
type: boolean
delete_skipped:
description: 'Delete skipped workflow runs'
required: false
default: true
type: boolean
jobs:
cleanup:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Environment Variables
run: |
echo "DAYS_TO_KEEP=${{ github.event.inputs.days_to_keep || '5' }}" >> $GITHUB_ENV
echo "DELETE_CANCELLED=${{ github.event.inputs.delete_cancelled || 'true' }}" >> $GITHUB_ENV
echo "DELETE_SKIPPED=${{ github.event.inputs.delete_skipped || 'true' }}" >> $GITHUB_ENV
- name: Cleanup of obsolete workflow runs
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/actions/workflow-cleanup/index.js')
await script({
github,
context,
core,
exec,
env: process.env
});