[TASK] Update dist/index.js

This commit is contained in:
Thorben Nissen 2020-04-10 20:15:02 +02:00
parent 36fd7e1343
commit 0e6fdec538

19
dist/index.js vendored
View file

@ -62,7 +62,7 @@ try {
const home = process.env['HOME']; const home = process.env['HOME'];
const homeSsh = home + '/.ssh'; const homeSsh = home + '/.ssh';
const privateKey = core.getInput('ssh-private-key').trim(); const privateKey = core.getInput('ssh-private-key');
if (!privateKey) { if (!privateKey) {
core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file."); core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file.");
@ -77,8 +77,21 @@ try {
console.log("Starting ssh-agent"); console.log("Starting ssh-agent");
const authSock = core.getInput('ssh-auth-sock'); const authSock = core.getInput('ssh-auth-sock');
child_process.execFileSync('ssh-agent', ['-a', authSock]); let sshAgentOutput = ''
core.exportVariable('SSH_AUTH_SOCK', authSock); if (authSock && authSock.length > 0) {
sshAgentOutput = child_process.execFileSync('ssh-agent', ['-a', authSock]);
} else {
sshAgentOutput = child_process.execFileSync('ssh-agent')
}
// Extract auth socket path and agent pid and set them as job variables
const lines = sshAgentOutput.toString().split("\n")
for (const lineNumber in lines) {
const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(lines[lineNumber])
if (matches && matches.length > 0) {
core.exportVariable(matches[1], matches[2])
}
}
console.log("Adding private key to agent"); console.log("Adding private key to agent");
privateKey.split(/(?=-----BEGIN)/).forEach(function(key) { privateKey.split(/(?=-----BEGIN)/).forEach(function(key) {