Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Persist inputs between the upload action and its post step.
  • Loading branch information
chrisgavin committed Oct 21, 2024
commit 602627410869d64f93a9ab25a6e0c3014395e80c
25 changes: 24 additions & 1 deletion lib/actions-util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/actions-util.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/upload-sarif-action-post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/upload-sarif-action-post.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/upload-sarif-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/upload-sarif-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/actions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
NlightNFotis marked this conversation as resolved.
Outdated
* 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;
}
}
};
2 changes: 2 additions & 0 deletions src/upload-sarif-action-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import * as core from "@actions/core";

import * as actionsUtil from "./actions-util";
import { getTemporaryDirectory } from "./actions-util";
import { getGitHubVersion } from "./api-client";
import * as debugArtifacts from "./debug-artifacts";
Expand All @@ -20,6 +21,7 @@ import {

async function runWrapper() {
try {
actionsUtil.restoreInputs();
Comment thread
NlightNFotis marked this conversation as resolved.
const logger = getActionsLogger();
const gitHubVersion = await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger);
Expand Down
2 changes: 2 additions & 0 deletions src/upload-sarif-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ async function run() {
const gitHubVersion = await getGitHubVersion();
checkActionVersion(getActionVersion(), gitHubVersion);

actionsUtil.persistInputs();
Comment thread
NlightNFotis marked this conversation as resolved.

const repositoryNwo = parseRepositoryNwo(
getRequiredEnvParam("GITHUB_REPOSITORY"),
);
Expand Down