@@ -56,28 +56,30 @@ async function waitForRunnerRegistered(label) {
5656 const retryIntervalSeconds = parseInt ( config . input . startupRetryIntervalSeconds ) || 10 ;
5757 const quietPeriodSeconds = parseInt ( config . input . startupQuietPeriodSeconds ) || 30 ;
5858
59- let waitSeconds = 0 ;
60-
6159 core . info ( `Waiting ${ quietPeriodSeconds } s for the AWS EC2 instance to be registered in GitHub as a new self-hosted runner` ) ;
6260 await new Promise ( ( r ) => setTimeout ( r , quietPeriodSeconds * 1000 ) ) ;
6361 core . info ( `Checking every ${ retryIntervalSeconds } s if the GitHub self-hosted runner is registered` ) ;
6462 core . info ( `The maximum waiting time is ${ timeoutMinutes } minutes` ) ;
63+
64+ const startTime = Date . now ( ) ;
65+ const timeoutMs = timeoutMinutes * 60 * 1000 ;
66+
6567 return new Promise ( ( resolve , reject ) => {
6668 const interval = setInterval ( async ( ) => {
69+ const elapsedMs = Date . now ( ) - startTime ;
6770 const runner = await getRunner ( label ) ;
6871
6972 if ( runner && runner . status === 'online' ) {
7073 core . info ( `GitHub self-hosted runner ${ runner . name } is registered and ready to use` ) ;
7174 clearInterval ( interval ) ;
7275 resolve ( ) ;
73- } else if ( waitSeconds > timeoutMinutes * 60 ) {
76+ } else if ( elapsedMs >= timeoutMs ) {
7477 core . error ( 'GitHub self-hosted runner registration error' ) ;
7578 clearInterval ( interval ) ;
7679 reject (
7780 `A timeout of ${ timeoutMinutes } minutes is exceeded. Your AWS EC2 instance was not able to register itself in GitHub as a new self-hosted runner.` ,
7881 ) ;
7982 } else {
80- waitSeconds += retryIntervalSeconds ;
8183 core . info ( 'Checking...' ) ;
8284 }
8385 } , retryIntervalSeconds * 1000 ) ;
0 commit comments