👷 feat(ci): add scheduled cache cleanup workflow

This commit is contained in:
rE-Bo0t.bx1
2025-12-05 20:48:52 +08:00
parent 49c9f69918
commit 911a44eef4

34
.github/workflows/cleanup.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: 🗑️🧹
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
permissions:
actions: write
jobs:
clear-cache:
runs-on: ubuntu-latest
steps:
- name: 🗑️ Clear GitHub Actions Cache
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
echo "🔍 Fetching list of caches..."
# Get all cache keys
cacheKeys=$(gh cache list --limit 100 --repo $REPO --json key --jq '.[].key')
if [ -z "$cacheKeys" ]; then
echo "✅ No caches found to clear."
exit 0
fi
echo "🗑️ Deleting caches..."
for key in $cacheKeys; do
echo " - Deleting $key"
gh cache delete "$key" --repo $REPO || echo " ⚠️ Failed to delete $key (might already be gone)"
done
echo "🎉 Cache cleanup complete."