From be44a3e6ff4ca17ff3ebccdf4d6321348672e188 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Thu, 28 Jan 2021 18:25:11 +0100 Subject: [PATCH] introduce a new sharedKey option fixes #6 --- README.md | 3 +++ action.yml | 3 +++ src/common.ts | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 752360a..d189d2d 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ sensible defaults. : `key` An optional key that is added to the automatic cache key. +: `sharedKey` +An additional key that is stable over multiple jobs. + : `working-directory` The working directory the action operates in, is case the cargo project is not located in the repo root. diff --git a/action.yml b/action.yml index fe29ead..164c909 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ inputs: key: description: "An additional key for the cache" required: false + sharedKey: + description: "An additional cache key that is stable over multiple jobs" + required: false working-directory: description: "The working directory this action should operate in" required: false diff --git a/src/common.ts b/src/common.ts index bbcc974..d5df5be 100644 --- a/src/common.ts +++ b/src/common.ts @@ -49,14 +49,19 @@ export async function getCacheConfig(): Promise { let key = `v0-rust-`; - let inputKey = core.getInput("key"); - if (inputKey) { - key += `${inputKey}-`; - } + const sharedKey = core.getInput("sharedKey"); + if (sharedKey) { + key += `${sharedKey}-`; + } else { + const inputKey = core.getInput("key"); + if (inputKey) { + key += `${inputKey}-`; + } - const job = process.env.GITHUB_JOB; - if (job) { - key += `${job}-`; + const job = process.env.GITHUB_JOB; + if (job) { + key += `${job}-`; + } } key += await getRustKey();