Skip to content

Commit

Permalink
Use sizeInBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Feb 13, 2025
1 parent 4c87324 commit 9ba26cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/cache-cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Reference:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries

# Reference:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries

name: Cleanup caches by a branch
on:
pull_request:
Expand All @@ -21,7 +24,7 @@ jobs:
echo "[DEBUG] Fetching cache list..."
# Get full cache details
CACHE_LIST=$(gh cache list --ref $BRANCH --limit 100 --json key,size,createdAt,id)
CACHE_LIST=$(gh cache list --ref $BRANCH --limit 100 --json key,sizeInBytes,createdAt,id)
if [ -z "$CACHE_LIST" ] || [ "$CACHE_LIST" = "[]" ]; then
echo "[DEBUG] No caches found"
Expand All @@ -34,7 +37,7 @@ jobs:
echo "|----------|-----------|------|------------|--------|" >> $GITHUB_STEP_SUMMARY
# Extract IDs and process deletions
echo "$CACHE_LIST" | jq -r '.[] | [.id, .key, .size, .createdAt] | @tsv' | while IFS=$'\t' read -r id key size created; do
echo "$CACHE_LIST" | jq -r '.[] | [.id, .key, .sizeInBytes, .createdAt] | @tsv' | while IFS=$'\t' read -r id key size created; do
# Convert size to human readable format
if [ $size -ge 1048576 ]; then
readable_size=$(echo "scale=2; $size/1048576" | bc)"MB"
Expand Down

0 comments on commit 9ba26cb

Please sign in to comment.