Skip to content

Support --ref parameter in gh cache delete #11425

@luxass

Description

@luxass

Describe the feature or problem you'd like to solve

The gh cache delete command currently lacks support for the --ref parameter to narrow the caches to delete down.

GitHub's REST API has support for the --ref query parameter: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-github-actions-caches-for-a-repository-using-a-cache-key

Proposed solution

Add a --ref flag to the gh cache delete command that accepts Git references in the same format as gh cache list --ref:

  • gh cache delete <key> --ref refs/heads/main
  • gh cache delete <key> --ref refs/pull/123/merge

Benefits:

  • Safer automated cleanup: CI workflows can clean up PR-specific caches without affecting other branches
  • Better cache management: Users can target specific branches for cache deletion
  • Consistency: Aligns the delete command with the list command's filtering capabilities

Additional context

I will gladly open a PR for this, if this is a welcoming change :)

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLIgh-cacherelating to the gh cache commandhelp wantedContributions welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions