mirror of
https://github.com/actions/cache.git
synced 2025-03-13 11:47:00 +00:00
The skip-save option allows users to force the cache to skip saving the cache. skip-save can be set to a constant or to an expression that will be evaluated at the end of the CI job, such as an environment variable. This is for #498
33 lines
1 KiB
TypeScript
33 lines
1 KiB
TypeScript
import { Inputs } from "../constants";
|
|
|
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
|
function getInputName(name: string): string {
|
|
return `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
|
|
}
|
|
|
|
export function setInput(name: string, value: string): void {
|
|
process.env[getInputName(name)] = value;
|
|
}
|
|
|
|
interface CacheInput {
|
|
path: string;
|
|
key: string;
|
|
restoreKeys?: string[];
|
|
skipSave?: string;
|
|
}
|
|
|
|
export function setInputs(input: CacheInput): void {
|
|
setInput(Inputs.Path, input.path);
|
|
setInput(Inputs.Key, input.key);
|
|
input.skipSave && setInput(Inputs.SkipSave, input.skipSave);
|
|
input.restoreKeys &&
|
|
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
|
}
|
|
|
|
export function clearInputs(): void {
|
|
delete process.env[getInputName(Inputs.Path)];
|
|
delete process.env[getInputName(Inputs.Key)];
|
|
delete process.env[getInputName(Inputs.SkipSave)];
|
|
delete process.env[getInputName(Inputs.RestoreKeys)];
|
|
delete process.env[getInputName(Inputs.UploadChunkSize)];
|
|
}
|