introduce a new sharedKey option

fixes #6
This commit is contained in:
Arpad Borsos 2021-01-28 18:25:11 +01:00
parent 2639a56bb8
commit be44a3e6ff
3 changed files with 18 additions and 7 deletions

View File

@ -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.

View File

@ -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

View File

@ -49,14 +49,19 @@ export async function getCacheConfig(): Promise<CacheConfig> {
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();