Improve restoreInputs

This commit is contained in:
Michael B. Gale
2026-10-19 22:18:06 +01:00
parent 5b8ae33509
commit 64ec5d5f67
3 changed files with 26 additions and 12 deletions

17
lib/entry-points.js generated
View File

@@ -170390,17 +170390,22 @@ var persistInputs = function(env = getEnv()) {
);
core4.saveState(persistedInputsKey, JSON.stringify(inputEnvironmentVariables));
};
function restoreInputs(logger2) {
function restoreInputs(action) {
try {
const persistedInputsValue = core4.getState(persistedInputsKey);
const persistedInputsValue = action.actions.getState(persistedInputsKey);
if (persistedInputsValue) {
const persistedInputs = JSON.parse(persistedInputsValue);
const persistedInputs = JSON.parse(
persistedInputsValue
);
if (!Array.isArray(persistedInputs)) {
throw new Error("Restored value is not an array.");
}
for (const [name, value] of persistedInputs) {
process.env[name] = value;
action.env.set(name, value);
}
}
} catch (err) {
logger2.error(`Unable to restore inputs: ${getErrorMessage(err)}`);
action.logger.error(`Unable to restore inputs: ${getErrorMessage(err)}`);
throw new Error(
"Failed to restore inputs from the state set by this action's main execution."
);
@@ -171783,7 +171788,7 @@ async function runInActions(action) {
actions: actionsEnv
};
if (isPostAction(action.name)) {
restoreInputs(logger2);
restoreInputs(actionState);
}
getJobUUID(actionState);
await action.run(actionState);