diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..c444683 --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -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." \ No newline at end of file