@@ -148362,7 +148362,7 @@ function wrappy (fn, cb) {
148362148362/***/ 1150:
148363148363/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
148364148364
148365- const { EC2Client, RunInstancesCommand, TerminateInstancesCommand, waitUntilInstanceRunning } = __nccwpck_require__(3802);
148365+ const { EC2Client, RunInstancesCommand, TerminateInstancesCommand, waitUntilInstanceRunning } = __nccwpck_require__(3802);
148366148366
148367148367const core = __nccwpck_require__(2186);
148368148368const config = __nccwpck_require__(4570);
@@ -148379,7 +148379,7 @@ function buildUserDataScript(githubRegistrationToken, label) {
148379148379 'source pre-runner-script.sh',
148380148380 'export RUNNER_ALLOW_RUNASROOT=1',
148381148381 `./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
148382- './run.sh'
148382+ './run.sh',
148383148383 ];
148384148384 } else {
148385148385 return [
@@ -148392,11 +148392,24 @@ function buildUserDataScript(githubRegistrationToken, label) {
148392148392 'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz',
148393148393 'export RUNNER_ALLOW_RUNASROOT=1',
148394148394 `./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
148395- './run.sh'
148395+ './run.sh',
148396148396 ];
148397148397 }
148398148398}
148399148399
148400+ function buildMarketOptions() {
148401+ if (config.input.marketType !== 'spot') {
148402+ return undefined;
148403+ }
148404+
148405+ return {
148406+ MarketType: config.input.marketType,
148407+ SpotOptions: {
148408+ SpotInstanceType: 'one-time',
148409+ },
148410+ };
148411+ }
148412+
148400148413async function startEc2Instance(label, githubRegistrationToken) {
148401148414 const ec2 = new EC2Client();
148402148415
@@ -148411,7 +148424,8 @@ async function startEc2Instance(label, githubRegistrationToken) {
148411148424 SubnetId: config.input.subnetId,
148412148425 UserData: Buffer.from(userData.join('\n')).toString('base64'),
148413148426 IamInstanceProfile: { Name: config.input.iamRoleName },
148414- TagSpecifications: config.tagSpecifications
148427+ TagSpecifications: config.tagSpecifications,
148428+ InstanceMarketOptions: buildMarketOptions(),
148415148429 };
148416148430
148417148431 try {
@@ -148429,7 +148443,7 @@ async function terminateEc2Instance() {
148429148443 const ec2 = new EC2Client();
148430148444
148431148445 const params = {
148432- InstanceIds: [config.input.ec2InstanceId]
148446+ InstanceIds: [config.input.ec2InstanceId],
148433148447 };
148434148448
148435148449 try {
@@ -148445,21 +148459,21 @@ async function terminateEc2Instance() {
148445148459async function waitForInstanceRunning(ec2InstanceId) {
148446148460 const ec2 = new EC2Client();
148447148461 try {
148448- core.info(`Cheking for instance ${ec2InstanceId} to be up and running`)
148462+ core.info(`Checking for instance ${ec2InstanceId} to be up and running`);
148449148463 await waitUntilInstanceRunning(
148450148464 {
148451148465 client: ec2,
148452148466 maxWaitTime: 300,
148453- }, {
148454- Filters: [
148455- {
148456- Name: 'instance-id',
148457- Values: [
148458- ec2InstanceId,
148459- ] ,
148460- } ,
148461- ] ,
148462- } );
148467+ },
148468+ {
148469+ Filters: [
148470+ {
148471+ Name: 'instance-id',
148472+ Values: [ ec2InstanceId] ,
148473+ } ,
148474+ ] ,
148475+ } ,
148476+ );
148463148477
148464148478 core.info(`AWS EC2 instance ${ec2InstanceId} is up and running`);
148465148479 return;
@@ -148472,7 +148486,7 @@ async function waitForInstanceRunning(ec2InstanceId) {
148472148486module.exports = {
148473148487 startEc2Instance,
148474148488 terminateEc2Instance,
148475- waitForInstanceRunning
148489+ waitForInstanceRunning,
148476148490};
148477148491
148478148492
@@ -148498,12 +148512,16 @@ class Config {
148498148512 iamRoleName: core.getInput('iam-role-name'),
148499148513 runnerHomeDir: core.getInput('runner-home-dir'),
148500148514 preRunnerScript: core.getInput('pre-runner-script'),
148515+ marketType: core.getInput('market-type'),
148501148516 };
148502148517
148503148518 const tags = JSON.parse(core.getInput('aws-resource-tags'));
148504148519 this.tagSpecifications = null;
148505148520 if (tags.length > 0) {
148506- this.tagSpecifications = [{ResourceType: 'instance', Tags: tags}, {ResourceType: 'volume', Tags: tags}];
148521+ this.tagSpecifications = [
148522+ { ResourceType: 'instance', Tags: tags },
148523+ { ResourceType: 'volume', Tags: tags },
148524+ ];
148507148525 }
148508148526
148509148527 // the values of github.context.repo.owner and github.context.repo.repo are taken from
@@ -148530,6 +148548,10 @@ class Config {
148530148548 if (!this.input.ec2ImageId || !this.input.ec2InstanceType || !this.input.subnetId || !this.input.securityGroupId) {
148531148549 throw new Error(`Not all the required inputs are provided for the 'start' mode`);
148532148550 }
148551+
148552+ if (this.marketType?.length > 0 && this.input.marketType !== 'spot') {
148553+ throw new Error('Invalid `market-type` input. Allowed values: spot.');
148554+ }
148533148555 } else if (this.input.mode === 'stop') {
148534148556 if (!this.input.label || !this.input.ec2InstanceId) {
148535148557 throw new Error(`Not all the required inputs are provided for the 'stop' mode`);
@@ -148617,7 +148639,7 @@ async function waitForRunnerRegistered(label) {
148617148639 let waitSeconds = 0;
148618148640
148619148641 core.info(`Waiting ${quietPeriodSeconds}s for the AWS EC2 instance to be registered in GitHub as a new self-hosted runner`);
148620- await new Promise(r => setTimeout(r, quietPeriodSeconds * 1000));
148642+ await new Promise((r) => setTimeout(r, quietPeriodSeconds * 1000));
148621148643 core.info(`Checking every ${retryIntervalSeconds}s if the GitHub self-hosted runner is registered`);
148622148644
148623148645 return new Promise((resolve, reject) => {
@@ -148627,7 +148649,9 @@ async function waitForRunnerRegistered(label) {
148627148649 if (waitSeconds > timeoutMinutes * 60) {
148628148650 core.error('GitHub self-hosted runner registration error');
148629148651 clearInterval(interval);
148630- reject(`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.`);
148652+ reject(
148653+ `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.`,
148654+ );
148631148655 }
148632148656
148633148657 if (runner && runner.status === 'online') {
0 commit comments