@@ -145419,28 +145419,30 @@ async function waitForRunnerRegistered(label) {
145419145419 const retryIntervalSeconds = parseInt(config.input.startupRetryIntervalSeconds) || 10;
145420145420 const quietPeriodSeconds = parseInt(config.input.startupQuietPeriodSeconds) || 30;
145421145421
145422- let waitSeconds = 0;
145423-
145424145422 core.info(`Waiting ${quietPeriodSeconds}s for the AWS EC2 instance to be registered in GitHub as a new self-hosted runner`);
145425145423 await new Promise((r) => setTimeout(r, quietPeriodSeconds * 1000));
145426145424 core.info(`Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered`);
145427145425 core.info(`The maximum waiting time is ${timeoutMinutes} minutes`);
145426+
145427+ const startTime = Date.now();
145428+ const timeoutMs = timeoutMinutes * 60 * 1000;
145429+
145428145430 return new Promise((resolve, reject) => {
145429145431 const interval = setInterval(async () => {
145432+ const elapsedMs = Date.now() - startTime;
145430145433 const runner = await getRunner(label);
145431145434
145432145435 if (runner && runner.status === 'online') {
145433145436 core.info(`GitHub self-hosted runner ${runner.name} is registered and ready to use`);
145434145437 clearInterval(interval);
145435145438 resolve();
145436- } else if (waitSeconds > timeoutMinutes * 60 ) {
145439+ } else if (elapsedMs >= timeoutMs ) {
145437145440 core.error('GitHub self-hosted runner registration error');
145438145441 clearInterval(interval);
145439145442 reject(
145440145443 `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.`,
145441145444 );
145442145445 } else {
145443- waitSeconds += retryIntervalSeconds;
145444145446 core.info('Checking...');
145445145447 }
145446145448 }, retryIntervalSeconds * 1000);
0 commit comments