Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickly delete all caches #35

Open
electrum opened this issue Oct 9, 2022 · 4 comments
Open

Quickly delete all caches #35

electrum opened this issue Oct 9, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@electrum
Copy link

electrum commented Oct 9, 2022

Describe the feature or problem you’d like to solve

We had a weird Maven failure in GHA that I suspected was due to a corrupted cache. I wanted to delete all of the caches for Maven. Doing this was more work than expected, since I had to write a shell loop to list the cache keys, parse out the key, then call delete.

Proposed solution

Adding an option to delete multiple keys would be helpful:

gh actions-cache delete --glob 'setup-java-Linux-maven-*'

Or even adding a --all flag to delete everything.

@electrum electrum added the enhancement New feature or request label Oct 9, 2022
@t-dedah
Copy link
Contributor

t-dedah commented Oct 11, 2022

Hi @electrum thank you for your wonderful suggestion! :)

Currently, we are planning for some enhancements on the current CLI on making it better and I've added your suggestion in list. We will prioritise based on the urgent needs and feedback from other users.

In the meantime, in case you wish to contribute, please feel free to raise a Pull Request for your suggested feature and we will be happy to review the same.

Thanks! :)

@wpbonelli
Copy link

wpbonelli commented Oct 20, 2022

for anyone else looking for a convenient bash one liner to delete all caches in the meantime:

gh actions-cache list | tail -n +5 | cut -f1 | xargs -I@ gh actions-cache delete @ --confirm

@redian
Copy link

redian commented Nov 21, 2022

In case you want to delete the largest ones first:

gh actions-cache list --sort size --order desc | tail -n +5 | cut -f1 | xargs -I@ gh actions-cache delete @ --confirm

@t-dedah t-dedah self-assigned this Jan 5, 2023
@smorimoto
Copy link

This one-liner does it in a simpler way, but also runs it in parallel as many as the number of cores of your machine.

gh actions-cache list --limit 100 | awk '{print $1}' | xargs -P $(getconf _NPROCESSORS_ONLN) -I HASH gh actions-cache delete HASH --confirm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants