From 27793b3b80296306dfa06d1d7ebe1b5e6407d282 Mon Sep 17 00:00:00 2001 From: Austin Jones Date: Mon, 21 Dec 2020 21:56:41 -0500 Subject: [PATCH] Add support for the `cache-hit` output --- action.yml | 3 +++ src/restore.ts | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/action.yml b/action.yml index 164c909..22b0847 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,9 @@ inputs: working-directory: description: "The working directory this action should operate in" required: false +outputs: + cache-hit: + description: 'A boolean value that indicates an exact match was found' runs: using: "node12" main: "dist/restore/index.js" diff --git a/src/restore.ts b/src/restore.ts index ec7f7b3..9f226c5 100644 --- a/src/restore.ts +++ b/src/restore.ts @@ -22,12 +22,22 @@ async function run() { await cleanTarget(packages); } + + setCacheHitOutput(restoreKey === key); } else { core.info("No cache found."); + + setCacheHitOutput(false); } } catch (e) { + setCacheHitOutput(false); + core.info(`[warning] ${e.message}`); } } +function setCacheHitOutput(cacheHit: boolean): void { + core.setOutput("cache-hit", cacheHit.toString()); +} + run();