Skip to content

feature: Filter GitHub Actions caches with a key #8674

Description

@toshimaru

Describe the feature or problem you’d like to solve

We have many caches in the repository, so I'd like to filter the caches using the key.

image)

Proposed solution

Add key prefix option to gh cache list

$ gh cache list --key cache-key-

Additional context

Activity

  1. williammartin commented on Feb 8, 2024

    @williammartin
    Member

    I think since the API presents this it makes a lot of sense for us to allow filtering on the command invocation. I'm going to label this as help wanted just to keep track of it, but I know you've already opened a PR.

    In the meantime, you can probably achieve what you want like so:

    gh cache list --json key --jq '.[] | select(.key | startswith("<YOUR PREFIX>"))'
    

    Adding whatever fields you want to the --json arg from this list:

      createdAt
      id
      key
      lastAccessedAt
      ref
      sizeInBytes
      version
    

    You'd probably need to up the --limit flag since this filtering is client side.

  2. added and removed on Feb 8, 2024
  3. toshimaru commented on Feb 8, 2024

    @toshimaru
    ContributorAuthor
    gh cache list --json key --jq '.[] | select(.key | startswith("<YOUR PREFIX>"))'
    

    Yes, I currently filter like that, but I have to add --limit 1000 (or higher) to retrieve a small number of caches, which is waste of resources.

    It would be nice to have a key option because it eliminates the need to consider the limit. 😉

  4. williammartin commented on Feb 9, 2024

    @williammartin
    Member

    Totally understand. It's a big win to avoid the extra bandwidth and processing. I just wanted to offer an alternative to you or anyone else who stumbled across this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions