Use runInActions for the analyze post-action

This commit is contained in:
Michael B. Gale
2026-10-19 19:37:28 +01:00
parent 0abe930e35
commit d9336e38a3
2 changed files with 90 additions and 63 deletions

View File

@@ -7,6 +7,12 @@ import * as fs from "fs";
import * as core from "@actions/core";
import {
ActionName,
runInActions,
type Action,
type ActionState,
} from "./action-common";
import * as actionsUtil from "./actions-util";
import { getGitHubVersion } from "./api-client";
import { getConfig } from "./config-utils";
@@ -16,15 +22,18 @@ import {
getJavaTempDependencyDir,
} from "./dependency-caching";
import { EnvVar } from "./environment";
import { getActionsLogger } from "./logging";
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
export async function runWrapper() {
/**
* The main functionality of the `analyze` post-action is implemented by this function.
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
*/
export async function run(action: ActionState<["Logger"]>) {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
const logger = action.logger;
try {
const logger = getActionsLogger();
actionsUtil.restoreInputs(logger);
const gitHubVersion = await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger);
@@ -68,3 +77,14 @@ export async function runWrapper() {
);
}
}
/** Defines the `analyze` post-action. */
const analyzePostAction: Action = {
name: ActionName.AnalyzePost,
run,
};
/** The main entry point for the `analyze` post-action. */
export async function runWrapper() {
await runInActions(analyzePostAction);
}