mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-05-19 22:34:45 +00:00
Add dry-run option
This commit is contained in:
parent
eda4a77b7c
commit
1bb6d2503c
13 changed files with 172 additions and 25 deletions
|
@ -3,7 +3,8 @@ export enum Inputs {
|
|||
Path = "path", // Input for cache, restore, save action
|
||||
RestoreKeys = "restore-keys", // Input for cache, restore action
|
||||
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
|
||||
EnableCrossOsArchive = "enableCrossOsArchive" // Input for cache, restore, save action
|
||||
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
|
||||
DryRun = "dry-run" // Input for cache, restore action
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
|
|
|
@ -39,7 +39,7 @@ async function restoreImpl(
|
|||
cachePaths,
|
||||
primaryKey,
|
||||
restoreKeys,
|
||||
{},
|
||||
{ dryRun: core.getBooleanInput(Inputs.DryRun) },
|
||||
enableCrossOsArchive
|
||||
);
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@ interface CacheInput {
|
|||
key: string;
|
||||
restoreKeys?: string[];
|
||||
enableCrossOsArchive?: boolean;
|
||||
dryRun?: string;
|
||||
}
|
||||
|
||||
export function setInputs(input: CacheInput): void {
|
||||
setInput(Inputs.Path, input.path);
|
||||
setInput(Inputs.Key, input.key);
|
||||
setInput(Inputs.DryRun, "false");
|
||||
input.restoreKeys &&
|
||||
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
||||
input.enableCrossOsArchive !== undefined &&
|
||||
|
@ -26,12 +28,14 @@ export function setInputs(input: CacheInput): void {
|
|||
Inputs.EnableCrossOsArchive,
|
||||
input.enableCrossOsArchive.toString()
|
||||
);
|
||||
input.dryRun && setInput(Inputs.DryRun, input.dryRun);
|
||||
}
|
||||
|
||||
export function clearInputs(): void {
|
||||
delete process.env[getInputName(Inputs.Path)];
|
||||
delete process.env[getInputName(Inputs.Key)];
|
||||
delete process.env[getInputName(Inputs.RestoreKeys)];
|
||||
delete process.env[getInputName(Inputs.DryRun)];
|
||||
delete process.env[getInputName(Inputs.UploadChunkSize)];
|
||||
delete process.env[getInputName(Inputs.EnableCrossOsArchive)];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue