@@ -21,23 +21,27 @@ try {
2121 fs . appendFileSync ( `${ homeSsh } /known_hosts` , '\ngithub.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\n' ) ;
2222 fs . appendFileSync ( `${ homeSsh } /known_hosts` , '\ngithub.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\n' ) ;
2323 fs . appendFileSync ( `${ homeSsh } /known_hosts` , '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n' ) ;
24-
25- console . log ( "Starting ssh-agent" ) ;
26-
24+
2725 const authSock = core . getInput ( 'ssh-auth-sock' ) ;
2826 const sshAgentArgs = ( authSock && authSock . length > 0 ) ? [ '-a' , authSock ] : [ ] ;
29-
30- // Extract auth socket path and agent pid and set them as job variables
31- child_process . execFileSync ( sshAgent , sshAgentArgs ) . toString ( ) . split ( "\n" ) . forEach ( function ( line ) {
32- const matches = / ^ ( S S H _ A U T H _ S O C K | S S H _ A G E N T _ P I D ) = ( .* ) ; e x p o r t \1/ . exec ( line ) ;
33-
34- if ( matches && matches . length > 0 ) {
35- // This will also set process.env accordingly, so changes take effect for this script
36- core . exportVariable ( matches [ 1 ] , matches [ 2 ] )
37- console . log ( `${ matches [ 1 ] } =${ matches [ 2 ] } ` ) ;
38- }
39- } ) ;
40-
27+
28+ if ( child_process . spawnSync ( sshAdd , [ '-l' ] , { env : { ...process . env , SSH_AUTH_SOCK : authSock || env [ 'SSH_AUTH_SOCK' ] } } ) !== 0 ) {
29+ console . log ( 'ssh-agent is already running, not starting a new one' )
30+ } else {
31+ console . log ( "Starting ssh-agent" ) ;
32+
33+ // Extract auth socket path and agent pid and set them as job variables
34+ child_process . execFileSync ( sshAgent , sshAgentArgs ) . toString ( ) . split ( "\n" ) . forEach ( function ( line ) {
35+ const matches = / ^ ( S S H _ A U T H _ S O C K | S S H _ A G E N T _ P I D ) = ( .* ) ; e x p o r t \1/ . exec ( line ) ;
36+
37+ if ( matches && matches . length > 0 ) {
38+ // This will also set process.env accordingly, so changes take effect for this script
39+ core . exportVariable ( matches [ 1 ] , matches [ 2 ] )
40+ console . log ( `${ matches [ 1 ] } =${ matches [ 2 ] } ` ) ;
41+ }
42+ } ) ;
43+ }
44+
4145 console . log ( "Adding private key(s) to agent" ) ;
4246
4347 privateKey . split ( / (? = - - - - - B E G I N ) / ) . forEach ( function ( key ) {
0 commit comments