@@ -21,19 +21,23 @@ try {
2121 execSync ( `ssh-agent -a "${ socketPath } "` )
2222} catch ( e ) {
2323 if ( e . message . includes ( 'Address already in use' ) ) {
24- core . info ( 'Agent already exists on sock. Skipping creation.' ) ;
24+ core . warning ( 'Agent already exists on sock. Skipping creation.' ) ;
2525 } else {
2626 core . setFailed ( e . message ) ;
2727 }
2828}
2929
30- // Pluck the pid and set values
31- const pid = parseInt ( execSync ( `fuser ${ socketPath } 2> /dev/null` , { encoding : 'utf-8' } ) ) ;
32- core . exportVariable ( 'SSH_AGENT_PID' , pid ) ;
33- core . exportVariable ( 'SSH_AUTH_SOCK' , socketPath ) ;
30+ // Pluck the pid and set values (if possible)
31+ try {
32+ const pid = parseInt ( execSync ( `fuser ${ socketPath } 2> /dev/null` , { encoding : 'utf-8' } ) ) ;
33+ core . exportVariable ( 'SSH_AGENT_PID' , pid ) ;
34+ core . setOutput ( 'agent-pid' , pid ) ;
35+ } catch ( e ) {
36+ core . warning ( 'PID capture failed (fuser). Skipping...' ) ;
37+ }
3438
3539// Add the key and set outputs
36- execSync ( `echo " ${ key } " | base64 -d | ssh-add -t ${ lifetimeInSeconds } -` ) ;
40+ core . exportVariable ( 'SSH_AUTH_SOCK' , socketPath ) ;
3741core . setOutput ( 'socket-path' , socketPath ) ;
38- core . setOutput ( 'agent-pid' , pid ) ;
42+ execSync ( `echo " ${ key } " | base64 -d | ssh-add -t ${ lifetimeInSeconds } -` ) ;
3943core . info ( 'Done; exiting.' ) ;
0 commit comments