How to Delete All GitHub Actions Caches at Once
Delete all GitHub Actions caches with a single command using GitHub CLI instead of clicking through the web interface.
Deleting GitHub Actions caches one by one through the web interface is tedious when you need to clear them all.
Prerequisites
Install GitHub CLI via Homebrew:
1
2
brew install gh
gh auth login
Solution
1
gh cache delete --all
Run this from your local repository directory. The --all flag handles bulk deletion in a single command.
For a specific repository from any directory:
1
gh cache delete --all -R owner/repo
Automated Cleanup Workflow
Schedule automatic cache cleanup with a GitHub Actions workflow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
name: Clear GitHub Actions Caches
on:
schedule:
- cron: "0 4 * * 0" # Weekly on Sundays at 4 AM
workflow_dispatch: # Manual trigger option
jobs:
clear-caches:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- run: gh cache delete --all --repo $
env:
GITHUB_TOKEN: $
The actions: write permission is required for cache deletion.
API Method
For programmatic control over individual caches:
1
2
3
4
5
6
gh api --paginate -H "Accept: application/vnd.github+json" \
/repos/owner/repo/actions/caches \
| jq '.actions_caches[].id' \
| xargs -I {} gh api --method DELETE \
-H "Accept: application/vnd.github+json" \
/repos/owner/repo/actions/caches/{}
This lists all cache IDs and deletes each one via the REST API.
Third-Party Action
The easimon/wipe-cache action provides workflow-based cache clearing:
1
2
3
4
- name: Clear caches
uses: easimon/wipe-cache@main
with:
dry-run: 'false'
When to Clear Caches
- Dependency lock file changes not reflecting in builds
- Cache corruption causing intermittent failures
- Significant changes to build configuration
- Storage quota approaching limits
☕ Support My Work
If you found this post helpful and want to support more content like this, you can buy me a coffee!
Your support helps me continue creating useful articles and tips for fellow developers. Thank you! 🙏