mirror of
https://github.com/github/codeql-action.git
synced 2026-11-08 22:19:50 +00:00
Use runInActions for the analyze post-action
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user