mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 03:45:31 +00:00
Allow refreshing cache also with granular save.
This commit is contained in:
parent
df9df7396d
commit
ed8571e5e3
6 changed files with 153 additions and 10 deletions
|
@ -82,7 +82,6 @@ export async function restoreImpl(
|
|||
} else {
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
}
|
||||
|
||||
return cacheKey;
|
||||
} catch (error: unknown) {
|
||||
core.setFailed((error as Error).message);
|
||||
|
|
|
@ -48,10 +48,26 @@ export async function saveImpl(
|
|||
{ 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)
|
||||
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save.
|
||||
|
||||
const restoredKey = stateProvider.getCacheState();
|
||||
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(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
const enableCrossOsArchive = utils.getInputAsBool(
|
||||
Inputs.EnableCrossOsArchive
|
||||
);
|
||||
restoredKey = await 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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue