Fix for Gitea
This commit is contained in:
@@ -9,6 +9,7 @@ import * as core from '@actions/core';
|
||||
import * as glob from '@actions/glob';
|
||||
|
||||
const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
|
||||
const STATE_CACHE_HIT = 'cache-hit';
|
||||
const CACHE_MATCHED_KEY = 'cache-matched-key';
|
||||
const CACHE_KEY_PREFIX = 'setup-java';
|
||||
|
||||
@@ -98,7 +99,7 @@ async function computeCacheKey(
|
||||
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
||||
);
|
||||
}
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-ABC-${process.arch}-${packageManager.id}-${fileHash}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +117,7 @@ export async function restore(id: string, cacheDependencyPath: string) {
|
||||
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey);
|
||||
if (matchedKey) {
|
||||
core.saveState(CACHE_MATCHED_KEY, matchedKey);
|
||||
core.setOutput('cache-hit', matchedKey === primaryKey);
|
||||
core.setOutput('cache-hit', true);
|
||||
core.info(`Cache restored from key: ${matchedKey}`);
|
||||
} else {
|
||||
core.setOutput('cache-hit', false);
|
||||
@@ -134,11 +135,12 @@ export async function save(id: string) {
|
||||
|
||||
// Inputs are re-evaluated before the post action, so we want the original key used for restore
|
||||
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
|
||||
const cacheHit = core.getState(STATE_CACHE_HIT);
|
||||
|
||||
if (!primaryKey) {
|
||||
core.warning('Error retrieving key from state.');
|
||||
return;
|
||||
} else if (matchedKey === primaryKey) {
|
||||
} else if (matchedKey === primaryKey || cacheHit) {
|
||||
// no change in target directories
|
||||
core.info(
|
||||
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
||||
|
||||
Reference in New Issue
Block a user