mirror of
https://github.com/actions/cache.git
synced 2026-02-15 06:30:32 +00:00
adding wrapper to save-only and testcases
This commit is contained in:
20
src/save-only.ts
Normal file
20
src/save-only.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { Inputs } from "./constants";
|
||||
import save from "./save";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
|
||||
async function runSaveAction(): Promise<void> {
|
||||
if (!core.getInput(Inputs.Key)) {
|
||||
utils.logWarning(`Error retrieving key from inputs.`);
|
||||
return;
|
||||
}
|
||||
saveOnly = true;
|
||||
|
||||
await save();
|
||||
}
|
||||
|
||||
runSaveAction();
|
||||
|
||||
export default runSaveAction;
|
||||
export let saveOnly: boolean;
|
||||
@@ -2,6 +2,7 @@ import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { Events, Inputs, State } from "./constants";
|
||||
import { saveOnly } from "./save-only";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
|
||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||
@@ -28,7 +29,9 @@ async function run(): Promise<void> {
|
||||
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
const primaryKey =
|
||||
core.getState(State.CachePrimaryKey) || core.getInput(Inputs.Key);
|
||||
saveOnly === true
|
||||
? core.getInput(Inputs.Key)
|
||||
: core.getState(State.CachePrimaryKey);
|
||||
|
||||
if (!primaryKey) {
|
||||
utils.logWarning(`Error retrieving key from state.`);
|
||||
@@ -58,6 +61,4 @@ async function run(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
export default run;
|
||||
|
||||
Reference in New Issue
Block a user