@@ -41,7 +41,8 @@ async function start(label) {
4141 const ec2disk = core . getInput ( "aws-disk" ) ;
4242 const ec2spot = core . getInput ( "aws-spot" ) != "false" ;
4343 const onejob = core . getInput ( "one-job" ) != "false" ;
44- // ephemeral runner will exit after one job so we will terminate instance sooner
44+ // ephemeral runner will exit after one job so we will terminate instance
45+ // sooner
4546 const ephemeral_str = onejob ? "--ephemeral" : "" ;
4647
4748 let ec2id ; // AWS EC2 instance id
@@ -58,9 +59,13 @@ async function start(label) {
5859 `export RUNNER_VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | sed -n \'s,.*"tag_name": "v\\(.*\\)".*,\\1,p\')` ,
5960 `curl -O -L https://github.com/actions/runner/releases/download/v$RUNNER_VERSION/actions-runner-linux-x64-$RUNNER_VERSION.tar.gz || shutdown -h now` ,
6061 `tar xf ./actions-runner-linux-x64-$RUNNER_VERSION.tar.gz || shutdown -h now` ,
61- `su gh_runner -c "./config.sh --unattended ${ ephemeral_str } --url https://github.com/${ repo } --token ${ reg_token } --name ${ label } _${ ec2type } _${ spot_str } --labels ${ label } --replace || shutdown -h now"` ,
62+ `su gh_runner -c "./config.sh --unattended ${
63+ ephemeral_str } --url https://github.com/${ repo } --token ${
64+ reg_token } --name ${ label } _${ ec2type } _${ spot_str } --labels ${
65+ label } --replace || shutdown -h now"`,
6266 // timebomb to avoid paying for stale AWS instances
63- `(sleep ${ timebomb } ; su gh_runner -c "./config.sh remove --token ${ reg_token } "; shutdown -h now) &` ,
67+ `(sleep ${ timebomb } ; su gh_runner -c "./config.sh remove --token ${
68+ reg_token } "; shutdown -h now) &`,
6469 `su gh_runner -c "./run.sh"` ,
6570 `su gh_runner -c "./config.sh remove --token ${ reg_token } "` ,
6671 `shutdown -h now` // in case we launch insance with
@@ -73,7 +78,7 @@ async function start(label) {
7378 InstanceType : ec2type ,
7479 InstanceInitiatedShutdownBehavior : "terminate" ,
7580 UserData : Buffer . from ( setup_github_actions_runner . join ( '\n' ) )
76- . toString ( 'base64' ) ,
81+ . toString ( 'base64' ) ,
7782 MinCount : 1 ,
7883 MaxCount : 1 ,
7984 TagSpecifications : [ {
@@ -90,10 +95,12 @@ async function start(label) {
9095 }
9196 const result = await ec2 . runInstances ( params ) . promise ( ) ;
9297 ec2id = result . Instances [ 0 ] . InstanceId ;
93- core . info ( `Created AWS EC2 ${ spot_str } instance ${ ec2id } of ${ ec2type } type with ${ label } label` ) ;
98+ core . info ( `Created AWS EC2 ${ spot_str } instance ${ ec2id } of ${
99+ ec2type } type with ${ label } label`) ;
94100 break ;
95101 } catch ( error ) {
96- core . warning ( `Error creating AWS EC2 ${ spot_str } instance of ${ ec2type } type with ${ label } label` ) ;
102+ core . warning ( `Error creating AWS EC2 ${ spot_str } instance of ${
103+ ec2type } type with ${ label } label`) ;
97104 last_error = error ;
98105 }
99106 }
@@ -114,13 +121,16 @@ async function start(label) {
114121 . promise ( ) ;
115122 for ( let i = 0 ; i < 2 ; i ++ ) {
116123 p = p . catch ( function ( ) {
117- core . warning ( `Error searching for running AWS EC2 instance ${ ec2id } with ${ label } label. Will retry.` ) ;
118- } ) . catch ( rejectDelay ) ;
124+ core . warning ( `Error searching for running AWS EC2 instance ${
125+ ec2id } with ${ label } label. Will retry.`) ;
126+ } ) . catch ( rejectDelay ) ;
119127 }
120128 p = p . then ( function ( ) {
121- core . info ( `Found running AWS EC2 instance ${ ec2id } with ${ label } label` ) ;
122- } ) . catch ( function ( error ) {
123- core . error ( `Error searching for running AWS EC2 instance ${ ec2id } with ${ label } label` ) ;
129+ core . info (
130+ `Found running AWS EC2 instance ${ ec2id } with ${ label } label` ) ;
131+ } ) . catch ( function ( error ) {
132+ core . error ( `Error searching for running AWS EC2 instance ${ ec2id } with ${
133+ label } label`) ;
124134 throw error ;
125135 } ) ;
126136}
@@ -154,9 +164,11 @@ async function stop(label) {
154164 try {
155165 await ec2 . terminateInstances ( { InstanceIds : [ instance . InstanceId ] } )
156166 . promise ( ) ;
157- core . info ( `Terminated AWS EC2 instance ${ instance . InstanceId } with label ${ label } ` ) ;
167+ core . info ( `Terminated AWS EC2 instance ${
168+ instance . InstanceId } with label ${ label } `) ;
158169 } catch ( error ) {
159- core . error ( `Error terminating AWS EC2 instance ${ instance . InstanceId } with label ${ label } ` ) ;
170+ core . error ( `Error terminating AWS EC2 instance ${
171+ instance . InstanceId } with label ${ label } `) ;
160172 last_error = error ;
161173 }
162174 }
@@ -190,13 +202,16 @@ async function stop(label) {
190202 // not remove runners still marked as active (with running job)
191203 for ( let i = 0 ; i < 5 ; i ++ ) {
192204 p = p . catch ( function ( ) {
193- core . warning ( `Error removing Github self-hosted runner ${ runner . id } with ${ label } . Will retry.` ) ;
194- } ) . catch ( rejectDelay ) ;
205+ core . warning ( `Error removing Github self-hosted runner ${
206+ runner . id } with ${ label } . Will retry.`) ;
207+ } ) . catch ( rejectDelay ) ;
195208 }
196209 p = p . then ( function ( ) {
197- core . info ( `Removed Github self-hosted runner ${ runner . id } with ${ label } ` ) ;
198- } ) . catch ( function ( error ) {
199- core . error ( `Error removing Github self-hosted runner ${ runner . id } with ${ label } ` ) ;
210+ core . info ( `Removed Github self-hosted runner ${ runner . id } with ${
211+ label } `) ;
212+ } ) . catch ( function ( error ) {
213+ core . error ( `Error removing Github self-hosted runner ${
214+ runner . id } with ${ label } `) ;
200215 last_error = error ;
201216 } ) ;
202217 }
0 commit comments