Skip to content

Commit 2a0f9f0

Browse files
committed
Use runInActions for the upload-sarif post-action
1 parent dca467b commit 2a0f9f0

2 files changed

Lines changed: 75 additions & 48 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 51 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/upload-sarif-action-post.ts‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,29 @@
55
*/
66
import * as core from "@actions/core";
77

8+
import {
9+
ActionName,
10+
runInActions,
11+
type Action,
12+
type ActionState,
13+
} from "./action-common";
814
import * as actionsUtil from "./actions-util";
915
import { getGitHubVersion } from "./api-client";
1016
import * as debugArtifacts from "./debug-artifacts";
1117
import { EnvVar } from "./environment";
12-
import { getActionsLogger, withGroup } from "./logging";
18+
import { withGroup } from "./logging";
1319
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
1420

15-
export async function runWrapper() {
21+
/**
22+
* The main functionality of the `upload-sarif` post-action is implemented by this function.
23+
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
24+
*/
25+
export async function run(action: ActionState<["Logger"]>) {
1626
// To capture errors appropriately, keep as much code within the try-catch as
1727
// possible, and only use safe functions outside.
28+
const logger = action.logger;
1829

1930
try {
20-
const logger = getActionsLogger();
21-
2231
// Restore inputs from `upload-sarif` Action.
2332
actionsUtil.restoreInputs(logger);
2433
const gitHubVersion = await getGitHubVersion();
@@ -43,3 +52,14 @@ export async function runWrapper() {
4352
);
4453
}
4554
}
55+
56+
/** Defines the `upload-sarif` post-action. */
57+
const uploadSarifPostAction: Action = {
58+
name: ActionName.UploadSarifPost,
59+
run,
60+
};
61+
62+
/** The main entry point for the `upload-sarif` post-action. */
63+
export async function runWrapper() {
64+
await runInActions(uploadSarifPostAction);
65+
}

0 commit comments

Comments
 (0)