Skip to content

Commit

Permalink
Set output cache-hit to indicate if cache was hit (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
schuenadel committed Apr 7, 2022
1 parent 0aa6f2a commit d2e3f41
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -70,6 +70,8 @@ The action has a built-in functionality for caching and restoring dependencies.
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`
- maven: `**/pom.xml`

The workflow output `cache-hit` is set to indicate if an exact match was found for the key [as actions/cache does](https://github.com/actions/cache/tree/main#outputs).

The cache input is optional, and caching is turned off by default.

#### Caching gradle dependencies
Expand Down
2 changes: 2 additions & 0 deletions dist/cleanup/index.js
Expand Up @@ -61925,9 +61925,11 @@ function restore(id) {
]);
if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey);
core.setOutput('cache-hit', matchedKey === primaryKey);
core.info(`Cache restored from key: ${matchedKey}`);
}
else {
core.setOutput('cache-hit', false);
core.info(`${packageManager.id} cache is not found`);
}
});
Expand Down
2 changes: 2 additions & 0 deletions dist/setup/index.js
Expand Up @@ -18662,9 +18662,11 @@ function restore(id) {
]);
if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey);
core.setOutput('cache-hit', matchedKey === primaryKey);
core.info(`Cache restored from key: ${matchedKey}`);
}
else {
core.setOutput('cache-hit', false);
core.info(`${packageManager.id} cache is not found`);
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/cache.ts
Expand Up @@ -77,8 +77,10 @@ export async function restore(id: string) {
]);
if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey);
core.setOutput('cache-hit', matchedKey === primaryKey);
core.info(`Cache restored from key: ${matchedKey}`);
} else {
core.setOutput('cache-hit', false);
core.info(`${packageManager.id} cache is not found`);
}
}
Expand Down

0 comments on commit d2e3f41

Please sign in to comment.