Clear cache in GitHub Actions

后端 未结 3 2324
悲哀的现实
悲哀的现实 2021-02-19 22:05

I am working on an R package and using GitHub Action (GHA) as a Continuous Integration (CI) provider. I cache R packages (dependencies) by using actions/cache. And now I want to

3条回答
  •  眼角桃花
    2021-02-19 22:35

    You cannot force a clear cache currently and it seems there is an open feature request for it at the moment https://github.com/actions/cache/issues/2. If I were you, I would post the request there as well so that they know that more people want the feature implemented.

    A few things to note about the action:

    There are not parameters in the action and not even in the toolkit package that this action is build on top of.

    Getting deep into the toolkit code they use a cache api url to do all the good stuff. This means we don't even know if that api supports it with the assumption that we try to test it out and see what else it provides by hitting it directly. Here is the line for the api call for which the base url is taken from env ACTIONS_CACHE_URL

    https://github.com/actions/toolkit/blob/c2bc747506bf562195a02bd4fdb1ff2a95d8b7ed/packages/cache/src/internal/cacheHttpClient.ts#L44

    npm package as reference https://www.npmjs.com/package/@actions/cache

    If we take a step back for a moment and go back to the github docs now that we have looked deep into the action/cache code and how it works,

    Per the github docs https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows

    There are two things to note,

    Once you create a cache, you cannot change the contents of an existing 
    cache but you can create a new cache with a new key.
    
    GitHub will remove any cache entries that have not been accessed in over 7 days.
    

提交回复
热议问题