use the key in state to save caches in the post process

This commit is contained in:
Kengo TODA 2021-07-16 07:28:13 +08:00
parent 6977c031ae
commit 7fe6c4d631
5 changed files with 102 additions and 17 deletions

9
dist/setup/index.js vendored
View file

@ -18998,9 +18998,14 @@ exports.restore = restore;
function save(id) {
return __awaiter(this, void 0, void 0, function* () {
const packageManager = findPackageManager(id);
const primaryKey = yield 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;