Persist inputs between the upload action and its post step.
This commit is contained in:
parent
af56b044b5
commit
6026274108
9 changed files with 60 additions and 4 deletions
|
|
@ -559,3 +559,29 @@ export async function runTool(
|
|||
}
|
||||
return stdout;
|
||||
}
|
||||
|
||||
const persistedInputsKey = "persisted_inputs";
|
||||
|
||||
/**
|
||||
* Persists all inputs to the action as state that can be retrieved later in the post-action.
|
||||
* This is need due to a runner bug that can cause inputs to be lost in the post-action.
|
||||
* https://github.com/actions/runner/issues/3514
|
||||
*/
|
||||
export const persistInputs = function () {
|
||||
const inputEnvironmentVariables = Object.entries(process.env).filter(
|
||||
([name]) => name.startsWith("INPUT_"),
|
||||
);
|
||||
core.saveState(persistedInputsKey, JSON.stringify(inputEnvironmentVariables));
|
||||
};
|
||||
|
||||
/**
|
||||
* Restores all inputs to the action from the persisted state.
|
||||
*/
|
||||
export const restoreInputs = function () {
|
||||
const persistedInputs = core.getState(persistedInputsKey);
|
||||
if (persistedInputs) {
|
||||
for (const [name, value] of JSON.parse(persistedInputs)) {
|
||||
process.env[name] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue