11import * as core from "@actions/core" ;
22
3+ import { Action , ActionState , runInActions } from "./action-common" ;
34import {
45 getActionVersion ,
56 getOptionalInput ,
@@ -11,13 +12,12 @@ import { getCodeQL } from "./codeql";
1112import { Config , getConfig } from "./config-utils" ;
1213import { EnvVar } from "./environment" ;
1314import { Language } from "./languages" ;
14- import { Logger , getActionsLogger } from "./logging" ;
15+ import { Logger } from "./logging" ;
1516import {
1617 StatusReportBase ,
1718 getActionsStatus ,
1819 createStatusReportBase ,
1920 sendStatusReport ,
20- sendUnhandledErrorStatusReport ,
2121 ActionName ,
2222} from "./status-report" ;
2323import { endTracingForCluster } from "./tracer-config" ;
@@ -26,7 +26,6 @@ import {
2626 checkDiskUsage ,
2727 checkGitHubVersionInRange ,
2828 ConfigurationError ,
29- getErrorMessage ,
3029 initializeEnvironment ,
3130 wrapError ,
3231} from "./util" ;
@@ -69,11 +68,10 @@ async function sendCompletedStatusReport(
6968 }
7069}
7170
72- async function run ( startedAt : Date ) {
71+ async function run ( { startedAt, logger } : ActionState < [ "Logger" ] > ) {
7372 // To capture errors appropriately, keep as much code within the try-catch as
7473 // possible, and only use safe functions outside.
7574
76- const logger = getActionsLogger ( ) ;
7775 let config : Config | undefined ;
7876 let currentLanguage : Language | undefined ;
7977 let languages : Language [ ] | undefined ;
@@ -142,18 +140,12 @@ async function run(startedAt: Date) {
142140 await sendCompletedStatusReport ( config , logger , startedAt , languages ?? [ ] ) ;
143141}
144142
143+ /** Defines the `autobuild` Action. */
144+ const autobuild : Action = {
145+ name : ActionName . Autobuild ,
146+ run,
147+ } ;
148+
145149export async function runWrapper ( ) {
146- const startedAt = new Date ( ) ;
147- const logger = getActionsLogger ( ) ;
148- try {
149- await run ( startedAt ) ;
150- } catch ( error ) {
151- core . setFailed ( `autobuild action failed. ${ getErrorMessage ( error ) } ` ) ;
152- await sendUnhandledErrorStatusReport (
153- ActionName . Autobuild ,
154- startedAt ,
155- error ,
156- logger ,
157- ) ;
158- }
150+ await runInActions ( autobuild ) ;
159151}
0 commit comments