Skip to content

Commit

Permalink
feat: Add job that removes old workflow runs
Browse files Browse the repository at this point in the history
/kind feat
/area ci

Add script and schedule workflow that removes workflow runs older than specific threshold.

Workflow runs every night at 0:11 UTC and removes up to 500 runs at a time.

feat: Add job that removes old workflow runs

/kind feat
/area ci

Add script and schedule workflow that removes workflow runs older than specific threshold.

Workflow runs every night at 0:11 UTC and removes up to 500 runs at a time.
  • Loading branch information
Ressetkk committed Nov 15, 2024
1 parent fed7ed3 commit a749b00
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci-cleanup-workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
schedule:
- cron: "11 0 * * *"

permissions:
actions: write

jobs:
cleanup-workflows:
runs-on: ubuntu-latest
steps:
- id: cleanup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DAYS_AFTER: 60 days
LIMIT: 500
run: |
DATE="$(date -d "-$DAYS_AFTER" +%F)"
echo "Removing workflow runs older than $DATE..."
gh run list --json databaseId -q '.[].databaseId' --created "<=$DATE" --limit "$LIMIT" |
xargs -IID -P 15 gh run delete ID

0 comments on commit a749b00

Please sign in to comment.