gh cache delete: Prune Actions Caches in CI
gh cache delete removes one Actions cache by key or ID, or every cache with --all.
Cleanup jobs delete stale caches to reclaim the per-repo storage limit and force a fresh restore on the next run.
What it does
gh cache delete removes a cache identified by its key or numeric ID. --all deletes every cache in the repository. It pairs naturally with gh cache list to find which keys to prune.
Common usage
gh cache delete node-modules-abc123
gh cache delete 42
gh cache delete --all
gh cache delete --all --succeed-on-no-cachesFlags
| Flag | What it does |
|---|---|
| <cache-key | cache-id> | The cache to delete |
| -a, --all | Delete every cache in the repository |
| --succeed-on-no-caches | Exit 0 even when there are no caches to delete |
| -R, --repo <owner/repo> | Target a specific repository |
In CI
Set GH_TOKEN and permissions: { actions: write }. Without --succeed-on-no-caches, gh cache delete --all returns a non-zero exit when no caches exist, which can fail a cleanup job; add the flag for idempotent runs.
Common errors in CI
"Resource not accessible by integration" or "HTTP 403" means the token lacks actions: write. "no caches to delete" with --all exits non-zero unless you add --succeed-on-no-caches. A wrong key reports the cache was not found.