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.
  • Loading branch information
Ressetkk committed Nov 14, 2024
1 parent fed7ed3 commit 1770682
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:
- "11 0 * * *"

permissions:
actions: write

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- id: cleanup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AFTER: "14d"
LIMIT: 500
run: |
DATE="$(date -uI -v -$AFTER)"
echo "Removing workflow runs older than $AFTER..."
gh run list --json databaseId -q '.[].databaseId' --created "<=$DATE" --limit "$LIMIT" | \
xargs -IID gh run delete ID

0 comments on commit 1770682

Please sign in to comment.