mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 10:26:46 +00:00
use the key in state to save caches in the post process
This commit is contained in:
parent
6977c031ae
commit
7fe6c4d631
5 changed files with 102 additions and 17 deletions
10
src/cache.ts
10
src/cache.ts
|
@ -90,9 +90,15 @@ export async function restore(id: string) {
|
|||
*/
|
||||
export async function save(id: string) {
|
||||
const packageManager = findPackageManager(id);
|
||||
const primaryKey = await computeCacheKey(packageManager);
|
||||
const matchedKey = core.getState(CACHE_MATCHED_KEY);
|
||||
if (matchedKey === primaryKey) {
|
||||
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
||||
|
||||
if (!primaryKey) {
|
||||
core.warning('Error retrieving key from state.');
|
||||
return;
|
||||
} else if (matchedKey === primaryKey) {
|
||||
// no change in target directories
|
||||
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue