diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 4573ec8..faab1cd 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -396,6 +396,8 @@ test("restore with lookup-only set", async () => { expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true"); - expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`); + expect(infoMock).toHaveBeenCalledWith( + `Cache would have been restored from key: ${key}` + ); expect(failedMock).toHaveBeenCalledTimes(0); }); diff --git a/action.yml b/action.yml index 1eb19b9..5c6fa87 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ inputs: default: 'false' required: false lookup-only: - description: 'Skip downloading cache. Only check if cache entry exists' + description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache' default: 'false' required: false outputs: diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 70c54b8..c0c0214 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -50520,7 +50520,12 @@ function restoreImpl(stateProvider) { stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey); const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey); core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString()); - core.info(`Cache restored from key: ${cacheKey}`); + if (lookupOnly) { + core.info(`Cache would have been restored from key: ${cacheKey}`); + } + else { + core.info(`Cache restored from key: ${cacheKey}`); + } return cacheKey; } catch (error) { diff --git a/dist/restore/index.js b/dist/restore/index.js index e55e25b..83fc4f6 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -50520,7 +50520,12 @@ function restoreImpl(stateProvider) { stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey); const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey); core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString()); - core.info(`Cache restored from key: ${cacheKey}`); + if (lookupOnly) { + core.info(`Cache would have been restored from key: ${cacheKey}`); + } + else { + core.info(`Cache restored from key: ${cacheKey}`); + } return cacheKey; } catch (error) { diff --git a/restore/README.md b/restore/README.md index a0be630..6571aef 100644 --- a/restore/README.md +++ b/restore/README.md @@ -10,7 +10,7 @@ The restore action restores a cache. It works similarly to the `cache` action ex * `path` - A list of files, directories, and wildcard patterns to restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. * `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. * `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false` -* `lookup-only` - Skip downloading cache. Only check if cache entry exists. Default: `false` +* `lookup-only` - Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache. Default: `false` ### Outputs diff --git a/restore/action.yml b/restore/action.yml index 6dbca00..21be5f0 100644 --- a/restore/action.yml +++ b/restore/action.yml @@ -20,7 +20,7 @@ inputs: default: 'false' required: false lookup-only: - description: 'Skip downloading cache. Only check if cache entry exists' + description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache' default: 'false' required: false outputs: diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 048d9fa..275a971 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -70,7 +70,11 @@ async function restoreImpl( ); core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString()); - core.info(`Cache restored from key: ${cacheKey}`); + if (lookupOnly) { + core.info(`Cache would have been restored from key: ${cacheKey}`); + } else { + core.info(`Cache restored from key: ${cacheKey}`); + } return cacheKey; } catch (error: unknown) {