@@ -7,7 +7,6 @@ function setOutput(label) {
77 core . setOutput ( 'label' , label )
88}
99
10- // This variable should only be defined for cleanup purpose.
1110let runnerName
1211
1312async function cleanup ( ) {
@@ -30,27 +29,30 @@ async function start() {
3029 for ( let i = 1 ; i <= 3 ; i ++ ) {
3130 try {
3231 startInstanceResponse = await slab . startInstanceRequest ( )
33- runnerName = startInstanceResponse . runner_name
32+
33+ const waitGithubResponse = await slab . waitForGithub (
34+ startInstanceResponse . task_id ,
35+ 'configuration_fetching'
36+ )
37+
38+ runnerName = waitGithubResponse . configuration_fetching . runner_name
39+ setOutput ( runnerName )
40+
41+ core . info (
42+ `${ provider } instance details: ${ waitGithubResponse . configuration_fetching . details } `
43+ )
3444 break
3545 } catch ( error ) {
3646 core . info ( 'Retrying request now...' )
3747 }
3848
3949 if ( i === 3 ) {
4050 core . setFailed (
41- `${ provider } instance start request has failed after 3 attempts`
51+ `${ provider } instance start request has failed after 3 attempts (reason: configuration fetching has failed) `
4252 )
4353 }
4454 }
4555
46- setOutput ( startInstanceResponse . runner_name )
47-
48- core . info (
49- `${ provider } instance details: ${ JSON . stringify (
50- startInstanceResponse . details
51- ) } `
52- )
53-
5456 try {
5557 const waitInstanceResponse = await slab . waitForInstance (
5658 startInstanceResponse . task_id ,
@@ -60,10 +62,10 @@ async function start() {
6062 const instanceId = waitInstanceResponse . start . instance_id
6163 core . info ( `${ provider } instance started with ID: ${ instanceId } ` )
6264
63- await waitForRunnerRegistered ( startInstanceResponse . runner_name )
65+ await waitForRunnerRegistered ( runnerName )
6466 } catch ( error ) {
6567 core . info ( `Clean up after error, stop ${ provider } instance` )
66- await slab . stopInstanceRequest ( startInstanceResponse . runner_name )
68+ await slab . stopInstanceRequest ( runnerName )
6769 core . setFailed ( `${ provider } instance start has failed` )
6870 }
6971}
@@ -74,6 +76,19 @@ async function stop() {
7476 for ( let i = 1 ; i <= 3 ; i ++ ) {
7577 try {
7678 stopInstanceResponse = await slab . stopInstanceRequest ( config . input . label )
79+
80+ const waitGithubResponse = await slab . waitForGithub (
81+ stopInstanceResponse . task_id ,
82+ 'runner_unregister'
83+ )
84+ const taskStatus =
85+ waitGithubResponse . runner_unregister . status . toLowerCase ( )
86+ if ( taskStatus === 'done' ) {
87+ core . info (
88+ `Runner ${ config . input . label } unregistered from GitHub successfully`
89+ )
90+ }
91+
7792 break
7893 } catch ( error ) {
7994 core . info ( 'Retrying request now...' )
0 commit comments