mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-06-28 05:33:45 +00:00
[TASK] Update dist/index.js
This commit is contained in:
parent
36fd7e1343
commit
0e6fdec538
1 changed files with 17 additions and 4 deletions
19
dist/index.js
vendored
19
dist/index.js
vendored
|
@ -62,7 +62,7 @@ try {
|
|||
const home = process.env['HOME'];
|
||||
const homeSsh = home + '/.ssh';
|
||||
|
||||
const privateKey = core.getInput('ssh-private-key').trim();
|
||||
const privateKey = core.getInput('ssh-private-key');
|
||||
|
||||
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.");
|
||||
|
@ -77,8 +77,21 @@ try {
|
|||
|
||||
console.log("Starting ssh-agent");
|
||||
const authSock = core.getInput('ssh-auth-sock');
|
||||
child_process.execFileSync('ssh-agent', ['-a', authSock]);
|
||||
core.exportVariable('SSH_AUTH_SOCK', authSock);
|
||||
let sshAgentOutput = ''
|
||||
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");
|
||||
privateKey.split(/(?=-----BEGIN)/).forEach(function(key) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue