Skip to content

Cache Cleanup

Cache Cleanup #811

Workflow file for this run

---
name: Cache Cleanup
on:
schedule:
- cron: '0 17 * * *'
- cron: '30 18 * * *'
workflow_dispatch:
permissions:
actions: write
jobs:
cleanup:
name: Cleanup Caches
runs-on: ubuntu-latest
steps:
- name: Get all cache keys
id: caches
run: |
gh cache list --limit 100 --json id,key --jq '.[].id' > cache_ids.txt
CACHE_COUNT=$(wc -l < cache_ids.txt)
echo "Found $CACHE_COUNT caches to delete"
echo "cache_count=$CACHE_COUNT" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
- name: Delete all caches
if: steps.caches.outputs.cache_count != '0'
run: |
set +e # Don't fail if some caches can't be deleted
while read -r cache_id; do
echo "Deleting cache: $cache_id"
gh cache delete "$cache_id"
done < cache_ids.txt
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
- name: Summary
run: |
echo "Cache cleanup completed"
if [ "${{ steps.caches.outputs.cache_count }}" = "0" ]; then
echo "No caches to delete"
else
echo "Deleted ${{ steps.caches.outputs.cache_count }} caches"
fi