Quantcast
Channel: Clear cache in GitHub Actions - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by windwerfer for Clear cache in GitHub Actions

$
0
0

keep the last cache with this bash function (add it to your .bashrc file)

function gh_clear_old_caches(){  GH_REPO='your_github_user/your_repository'  echo "deleting all caches, except the last"  gh api --paginate -H "Accept: application/vnd.github+json" \"/repos/${GH_REPO}/actions/caches" \        | for ID in `jq '.actions_caches | sort_by(.id) | .[:-1][] | .id '`; \        do echo "Deleting cache id ${ID}"; \        gh api --method DELETE -H "Accept: application/vnd.github+json" "/repos/${GH_REPO}/actions/caches/${ID}" | echo; \    done  }

name completion works with bash functions as well:

gh_<tab>

the addition in this one is that jq first sorts the result by id (assuming that the most recent one has the largest).

[:-1] means every id, except the last.


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>