3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-30 15:15:52 +00:00

Allow refreshing cache also with granular save.

This commit is contained in:
Gregorio Litenstein 2023-04-07 21:53:06 -04:00
parent 34ae092a8c
commit d35302b225
No known key found for this signature in database
GPG key ID: 4EB52A1A9CE2C63F
6 changed files with 153 additions and 10 deletions

View file

@ -77561,8 +77561,16 @@ function saveImpl(stateProvider) {
return;
}
const refreshCache = utils.getInputAsBool(constants_1.Inputs.RefreshCache, { required: false });
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save (NO-OP in case of SaveOnly action)
const restoredKey = stateProvider.getCacheState();
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save.
let restoredKey = stateProvider.getCacheState();
if (refreshCache && !restoredKey) {
// If getCacheState didn't give us a key, we're likely using granular actions. Do a lookup to see if we need to refresh or just do a regular save.
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
required: true
});
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
restoredKey = yield cache.restoreCache(cachePaths, primaryKey, [], { lookupOnly: true }, enableCrossOsArchive);
}
if (utils.isExactKeyMatch(primaryKey, restoredKey)) {
const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env || null;
if (GITHUB_TOKEN && GITHUB_REPOSITORY && refreshCache === true) {