Skip to content

Cleanup Old Artifacts #90

Cleanup Old Artifacts

Cleanup Old Artifacts #90

Workflow file for this run

name: Cleanup Old Artifacts
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM
workflow_dispatch:
jobs:
cleanup-artifacts:
name: Delete Old Artifacts
runs-on: ubuntu-latest
steps:
- name: Delete artifacts older than 7 days
uses: c-hive/gha-remove-artifacts@v1
with:
age: '7 days'
skip-recent: 5
cleanup-caches:
name: Cleanup Old Caches
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
echo "Triggering cache cleanup"
gh extension install actions/gh-actions-cache
echo "Fetching list of cache keys"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.ref }}
continue-on-error: true
cleanup-old-workflow-runs:
name: Delete Old Workflow Runs
runs-on: ubuntu-latest
steps:
- name: Delete workflow runs older than 30 days
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 30
keep_minimum_runs: 6