Skip to content

Commit

Permalink
Set cache-hit to true if any cache key matched
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed May 13, 2024
1 parent e962bc7 commit 157b3bd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion dist/save-cache/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/save-cache/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/restore-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function restoreCache(
}

let matchedKey: string | undefined
core.info(`Trying to restore cache with key: ${cacheKey}`)
try {
matchedKey = cacheLocalStoragePath
? await restoreCacheLocal(cacheKey)
Expand Down Expand Up @@ -63,10 +64,11 @@ function handleMatchResult(
if (matchedKey) {
core.saveState(STATE_CACHE_MATCHED_KEY, matchedKey)
core.info(`Cache restored from key: ${matchedKey}`)
core.setOutput('cache-hit', true)
} else {
core.info(`No cache found for key: ${primaryKey}`)
core.setOutput('cache-hit', false)
}
core.setOutput('cache-hit', matchedKey === primaryKey)
}

async function restoreCacheLocal(
Expand Down

0 comments on commit 157b3bd

Please sign in to comment.