You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Delete by key across all branches: Providing only key (no branch) now enters delete mode instead of list-only. List mode only activates when both branch and key are empty.
GitHub Actions job summary: Writes a markdown summary to $GITHUB_STEP_SUMMARY with a collapsible <details> table of matched objects. Works in list, dry-run, and delete modes. No-op when running locally.
Updated modes of operation
Scenario
Branch
Key
Dry-run
List all cache entries
(empty)
(empty)
n/a
Preview what would be deleted
feature/my-branch
(optional)
true
Delete cache for a branch
feature/my-branch
(optional)
false
Delete key across all branches
(empty)
sccache-Linux-
false
Test plan
Test list mode locally (no branch, no key) - still works
Test key-only delete with dry-run
Verify GITHUB_STEP_SUMMARY renders correctly in Actions UI (collapsible table)
Verify script works locally without GITHUB_STEP_SUMMARY set
This PR adds two features to the cache cleanup script:
Key-only deletion — the script now supports deleting a cache key across all branches. The list/delete mode logic changed: list mode only activates when both branch and key are empty; providing just a key now triggers delete mode. This enables cleanup scenarios like "delete all sccache-Linux-* across the entire repo."
GitHub Actions job summary — a new write_summary() function writes markdown output to $GITHUB_STEP_SUMMARY with object count, total size, and a collapsible table of matched keys. It writes in all three modes (list, dry-run, delete) and safely no-ops when running locally.
Supporting changes: refactored object row extraction into a shared extract_rows() helper to avoid duplicating the jq transform between table output and the summary.
What reviewers should know
Start with: the mode detection logic change at line 175 — this is the crux. Compare the old [[ -z "$INPUT_BRANCH" ]] check against the new [[ -z "$INPUT_BRANCH" && -z "$KEY_PATTERN" ]] to understand the three-way branch/key/both logic.
Watch for: the extract_rows() refactor. It's now the single source of truth for turning S3 object JSON into TSV rows — verify it's called correctly by both print_table() and write_summary(), and that TSV field order (size, date, key) matches expectations in both consumers.
GitHub Actions integration:write_summary() only writes if $GITHUB_STEP_SUMMARY exists (safe locally). Review the markdown table format — it needs to render cleanly in the Actions UI with the collapsible <details> wrapper.
Test the boundary cases:
Empty branch + empty key → list mode (unchanged behavior)
Empty branch + key-only → delete mode across all branches (new)
Branch + empty key → delete for that branch (unchanged)
The reason will be displayed to describe this comment to others. Learn more.
Conclusion: The feature logic and mode-switching are correct, but write_summary has a formatting bug that will surface immediately in any real run, and it duplicates extraction logic from print_table in a way that will cause silent drift over time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two additions to the cache cleanup script:
key(no branch) now enters delete mode instead of list-only. List mode only activates when both branch and key are empty.$GITHUB_STEP_SUMMARYwith a collapsible<details>table of matched objects. Works in list, dry-run, and delete modes. No-op when running locally.Updated modes of operation
feature/my-branchtruefeature/my-branchfalsesccache-Linux-falseTest plan
GITHUB_STEP_SUMMARYrenders correctly in Actions UI (collapsible table)GITHUB_STEP_SUMMARYset🤖 Generated with Claude Code