Skip to content

Commit

Permalink
Small fixes to append-timestamp option. (#127)
Browse files Browse the repository at this point in the history
fix append-timestamp option
  • Loading branch information
fruffy committed Jan 11, 2023
1 parent 9e5eadb commit 150e52a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ inputs:
description: "If 'false', do not save the cache, only restore."
default: true
append-timestamp:
description: "Append a timestamp to the cache key (default: true)"
default: true
description: "Append a timestamp to the cache key (default: true)"
default: true
required: false
runs:
using: "node16"
main: "dist/restore/index.js"
Expand Down
5 changes: 4 additions & 1 deletion dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59337,9 +59337,12 @@ async function run() {
}
else {
let saveKey = primaryKey;
if (_actions_core__WEBPACK_IMPORTED_MODULE_0__.getState("appendTimestamp")) {
if (_actions_core__WEBPACK_IMPORTED_MODULE_0__.getState("appendTimestamp") == "true") {
saveKey += new Date().toISOString();
}
else {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.debug("Not appending timestamp because 'append-timestamp' is not set to 'true'.");
}
const paths = [`.${ccacheVariant}`];
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Save cache using key "${saveKey}".`);
await _actions_cache__WEBPACK_IMPORTED_MODULE_1__.saveCache(paths, saveKey);
Expand Down
4 changes: 3 additions & 1 deletion src/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ async function run() : Promise<void> {
core.info("Not saving cache because no objects are cached.");
} else {
let saveKey = primaryKey;
if (core.getState("appendTimestamp")) {
if (core.getState("appendTimestamp") == "true") {
saveKey += new Date().toISOString();
} else {
core.debug("Not appending timestamp because 'append-timestamp' is not set to 'true'.");
}
const paths = [`.${ccacheVariant}`];

Expand Down

0 comments on commit 150e52a

Please sign in to comment.