Restore inputs in runInActions

This commit is contained in:
Michael B. Gale
2026-10-19 19:44:39 +01:00
parent bdbdfba109
commit f4e96ed27f
7 changed files with 18 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
import * as core from "@actions/core";
import { ActionsEnv, getActionsEnv } from "./actions-util";
import { ActionsEnv, getActionsEnv, restoreInputs } from "./actions-util";
import type { ApiClient } from "./api-client";
import { Env, ReadOnlyEnv } from "./environment";
import type { FeatureEnablement } from "./feature-flags";
@@ -9,6 +9,7 @@ import {
ActionName,
getDisplayActionName,
getJobUUID,
isPostAction,
sendUnhandledErrorStatusReport,
} from "./status-report";
import { getEnv, getErrorMessage, wrapError } from "./util";
@@ -180,6 +181,11 @@ export async function runInActions(action: Action) {
actions: actionsEnv,
};
// If this is a post-action, restore inputs from the main action.
if (isPostAction(action.name)) {
restoreInputs(logger);
}
// Create a unique identifier for this run.
getJobUUID(actionState);

View File

@@ -34,7 +34,6 @@ export async function run(action: ActionState<["Logger"]>) {
const logger = action.logger;
try {
actionsUtil.restoreInputs(logger);
const gitHubVersion = await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger);

View File

@@ -8,7 +8,6 @@ import * as core from "@actions/core";
import { runInActions, type Action, type ActionState } from "./action-common";
import {
restoreInputs,
getOptionalInput,
getTemporaryDirectory,
printDebugLogs,
@@ -66,9 +65,6 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
// Action saw, which is always a success.
const jobStatus = getOptionalInput("job-status");
// Restore inputs from `init` Action.
restoreInputs(logger);
const tmpDir = getTemporaryDirectory();
config = await getConfig(tmpDir, logger);

View File

@@ -29,9 +29,6 @@ export async function run(action: ActionState<["Logger"]>) {
const logger = action.logger;
try {
// Restore inputs from `start-proxy` Action.
actionsUtil.restoreInputs(logger);
// Kill the running proxy
const pid = core.getState("proxy-process-pid");
if (pid) {

View File

@@ -73,6 +73,11 @@ export const ACTION_DISPLAY_NAMES: Partial<Record<ActionName, string>> = {
[ActionName.UploadSarifPost]: "upload-sarif post-action",
};
/** Decides if {@link name} refers to a post-action. */
export function isPostAction(name: ActionName) {
return name.endsWith("-post");
}
/**
* Maps an {@link ActionName} to its display name. Usually that is the same, except
* for actions which have a different display name in {@link ACTION_DISPLAY_NAMES}.

View File

@@ -11,7 +11,6 @@ import {
type Action,
type ActionState,
} from "./action-common";
import * as actionsUtil from "./actions-util";
import { getGitHubVersion } from "./api-client";
import * as debugArtifacts from "./debug-artifacts";
import { EnvVar } from "./environment";
@@ -28,8 +27,6 @@ export async function run(action: ActionState<["Logger"]>) {
const logger = action.logger;
try {
// Restore inputs from `upload-sarif` Action.
actionsUtil.restoreInputs(logger);
const gitHubVersion = await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger);