@@ -5849,8 +5849,107 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
58495849} ;
58505850Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
58515851const core = __importStar ( __webpack_require__ ( 186 ) ) ;
5852- const github = __importStar ( __webpack_require__ ( 438 ) ) ;
5852+ const utils_1 = __webpack_require__ ( 314 ) ;
58535853const workflow_handler_1 = __webpack_require__ ( 971 ) ;
5854+ function waitForCompletionOrTimeout ( workflowHandler , checkStatusInterval , waitForCompletionTimeout ) {
5855+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
5856+ const start = Date . now ( ) ;
5857+ let first = true ;
5858+ let status ;
5859+ let result ;
5860+ do {
5861+ yield utils_1 . sleep ( checkStatusInterval ) ;
5862+ try {
5863+ result = yield workflowHandler . getWorkflowRunStatus ( ) ;
5864+ status = result . status ;
5865+ if ( first ) {
5866+ core . info ( `You can follow the running workflow here: ${ result . url } ` ) ;
5867+ first = false ;
5868+ }
5869+ core . debug ( `Worflow is running for ${ utils_1 . formatDuration ( Date . now ( ) - start ) } . Current status=${ status } ` ) ;
5870+ }
5871+ catch ( e ) {
5872+ core . warning ( `Failed to get workflow status: ${ e . message } ` ) ;
5873+ }
5874+ } while ( status !== workflow_handler_1 . WorkflowRunStatus . COMPLETED && ! utils_1 . isTimedOut ( start , waitForCompletionTimeout ) ) ;
5875+ return { result, start } ;
5876+ } ) ;
5877+ }
5878+ function computeConclusion ( start , waitForCompletionTimeout , result ) {
5879+ if ( utils_1 . isTimedOut ( start , waitForCompletionTimeout ) ) {
5880+ core . info ( `Workflow wait timed out` ) ;
5881+ core . setOutput ( 'workflow-conclusion' , workflow_handler_1 . WorkflowRunConclusion . TIMED_OUT ) ;
5882+ throw new Error ( 'Workflow run has failed due to timeout' ) ;
5883+ }
5884+ core . info ( `Workflow completed with conclusion=${ result === null || result === void 0 ? void 0 : result . conclusion } ` ) ;
5885+ const conclusion = result === null || result === void 0 ? void 0 : result . conclusion ;
5886+ core . setOutput ( 'workflow-conclusion' , conclusion ) ;
5887+ if ( conclusion === workflow_handler_1 . WorkflowRunConclusion . FAILURE )
5888+ throw new Error ( 'Workflow run has failed' ) ;
5889+ if ( conclusion === workflow_handler_1 . WorkflowRunConclusion . CANCELLED )
5890+ throw new Error ( 'Workflow run was cancelled' ) ;
5891+ if ( conclusion === workflow_handler_1 . WorkflowRunConclusion . TIMED_OUT )
5892+ throw new Error ( 'Workflow run has failed due to timeout' ) ;
5893+ }
5894+ //
5895+ // Main task function (async wrapper)
5896+ //
5897+ function run ( ) {
5898+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
5899+ try {
5900+ const args = utils_1 . getArgs ( ) ;
5901+ const workflowHandler = new workflow_handler_1 . WorkflowHandler ( args . token , args . workflowRef , args . owner , args . repo , args . ref ) ;
5902+ // Trigger workflow run
5903+ workflowHandler . triggerWorkflow ( args . inputs ) ;
5904+ core . info ( `Workflow triggered 🚀` ) ;
5905+ if ( ! args . waitForCompletion ) {
5906+ return ;
5907+ }
5908+ core . info ( `Waiting for workflow completion` ) ;
5909+ const { result, start } = yield waitForCompletionOrTimeout ( workflowHandler , args . checkStatusInterval , args . waitForCompletionTimeout ) ;
5910+ computeConclusion ( start , args . waitForCompletionTimeout , result ) ;
5911+ }
5912+ catch ( error ) {
5913+ core . setFailed ( error . message ) ;
5914+ }
5915+ } ) ;
5916+ }
5917+ //
5918+ // Call the main task run function
5919+ //
5920+ run ( ) ;
5921+
5922+
5923+ /***/ } ) ,
5924+
5925+ /***/ 314 :
5926+ /***/ ( function ( __unused_webpack_module , exports , __webpack_require__ ) {
5927+
5928+ "use strict" ;
5929+
5930+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
5931+ if ( k2 === undefined ) k2 = k ;
5932+ Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
5933+ } ) : ( function ( o , m , k , k2 ) {
5934+ if ( k2 === undefined ) k2 = k ;
5935+ o [ k2 ] = m [ k ] ;
5936+ } ) ) ;
5937+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
5938+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
5939+ } ) : function ( o , v ) {
5940+ o [ "default" ] = v ;
5941+ } ) ;
5942+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
5943+ if ( mod && mod . __esModule ) return mod ;
5944+ var result = { } ;
5945+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
5946+ __setModuleDefault ( result , mod ) ;
5947+ return result ;
5948+ } ;
5949+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
5950+ exports . formatDuration = exports . isTimedOut = exports . sleep = exports . getArgs = void 0 ;
5951+ const core = __importStar ( __webpack_require__ ( 186 ) ) ;
5952+ const github = __importStar ( __webpack_require__ ( 438 ) ) ;
58545953var TimeUnit ;
58555954( function ( TimeUnit ) {
58565955 TimeUnit [ TimeUnit [ "S" ] = 1000 ] = "S" ;
@@ -5897,12 +5996,15 @@ function getArgs() {
58975996 waitForCompletionTimeout
58985997 } ;
58995998}
5999+ exports . getArgs = getArgs ;
59006000function sleep ( ms ) {
59016001 return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
59026002}
6003+ exports . sleep = sleep ;
59036004function isTimedOut ( start , waitForCompletionTimeout ) {
59046005 return Date . now ( ) > start + waitForCompletionTimeout ;
59056006}
6007+ exports . isTimedOut = isTimedOut ;
59066008function formatDuration ( duration ) {
59076009 const durationSeconds = duration / 1000 ;
59086010 const hours = Math . floor ( durationSeconds / 3600 ) ;
@@ -5922,59 +6024,7 @@ function formatDuration(duration) {
59226024 }
59236025 return hoursStr + 'h ' + minutesStr + 'm ' + secondsStr + 's' ;
59246026}
5925- //
5926- // Main task function (async wrapper)
5927- //
5928- function run ( ) {
5929- return __awaiter ( this , void 0 , void 0 , function * ( ) {
5930- try {
5931- const args = getArgs ( ) ;
5932- const workflowHandler = new workflow_handler_1 . WorkflowHandler ( args . token , args . workflowRef , args . owner , args . repo , args . ref ) ;
5933- // Trigger workflow run
5934- workflowHandler . triggerWorkflow ( args . inputs ) ;
5935- core . info ( `Workflow triggered 🚀` ) ;
5936- if ( ! args . waitForCompletion ) {
5937- return ;
5938- }
5939- core . info ( `Waiting for workflow completion` ) ;
5940- const start = Date . now ( ) ;
5941- let status ;
5942- let result ;
5943- do {
5944- yield sleep ( args . checkStatusInterval ) ;
5945- try {
5946- result = yield workflowHandler . getWorkflowRunStatus ( ) ;
5947- status = result . status ;
5948- core . debug ( "Worflow is running for " + formatDuration ( Date . now ( ) - start ) ) ;
5949- }
5950- catch ( e ) {
5951- core . warning ( "Failed to get workflow status: " + e . message ) ;
5952- }
5953- } while ( status !== workflow_handler_1 . WorkflowRunStatus . COMPLETED && ! isTimedOut ( start , args . waitForCompletionTimeout ) ) ;
5954- if ( isTimedOut ( start , args . waitForCompletionTimeout ) ) {
5955- core . info ( `Workflow wait timed out` ) ;
5956- core . setOutput ( 'workflow-conclusion' , workflow_handler_1 . WorkflowRunConclusion . TIMED_OUT ) ;
5957- throw new Error ( 'Workflow run has failed due to timeout' ) ;
5958- }
5959- core . info ( `Workflow completed with conclusion=${ result === null || result === void 0 ? void 0 : result . conclusion } ` ) ;
5960- const conclusion = result === null || result === void 0 ? void 0 : result . conclusion ;
5961- core . setOutput ( 'workflow-conclusion' , conclusion ) ;
5962- if ( conclusion === workflow_handler_1 . WorkflowRunConclusion . FAILURE )
5963- throw new Error ( 'Workflow run has failed' ) ;
5964- if ( conclusion === workflow_handler_1 . WorkflowRunConclusion . CANCELLED )
5965- throw new Error ( 'Workflow run was cancelled' ) ;
5966- if ( conclusion === workflow_handler_1 . WorkflowRunConclusion . TIMED_OUT )
5967- throw new Error ( 'Workflow run has failed due to timeout' ) ;
5968- }
5969- catch ( error ) {
5970- core . setFailed ( error . message ) ;
5971- }
5972- } ) ;
5973- }
5974- //
5975- // Call the main task run function
5976- //
5977- run ( ) ;
6027+ exports . formatDuration = formatDuration ;
59786028
59796029
59806030/***/ } ) ,
@@ -6087,6 +6137,7 @@ class WorkflowHandler {
60876137 } ) ;
60886138 debug_1 . debug ( 'Workflow Run status' , response ) ;
60896139 return {
6140+ url : response . data . html_url ,
60906141 status : ofStatus ( response . data . status ) ,
60916142 conclusion : ofConclusion ( response . data . conclusion )
60926143 } ;
0 commit comments