mirror of
https://github.com/deployphp/action.git
synced 2025-03-31 02:16:36 +00:00
fix: get ssh agent details via regex instead
doesn't seem like eval persists the environment variables
This commit is contained in:
parent
dca1d5d96c
commit
7e185f2952
1 changed files with 9 additions and 3 deletions
12
index.js
12
index.js
|
@ -21,11 +21,17 @@ async function ssh() {
|
|||
fs.mkdirSync(sshHomeDir)
|
||||
}
|
||||
|
||||
await $`eval \`ssh-agent\``
|
||||
const sshAgentOutput = await $`ssh-agent`
|
||||
|
||||
const sshAgentSocket = await $`echo \$SSH_AUTH_SOCKET`
|
||||
const sshAgentSocket = sshAgentOutput
|
||||
.stdout
|
||||
.match(/SSH_AUTH_SOCK=(?<path>.*); export SSH_AUTH_SOCK;/)
|
||||
?.groups['path'] ?? null;
|
||||
|
||||
const sshAgentProcessId = await $`echo \$SSH_AGENT_PID`
|
||||
const sshAgentProcessId = sshAgentOutput
|
||||
.stdout
|
||||
.match(/SSH_AGENT_PID=(?<pid>\d+); export SSH_AGENT_PID;/)
|
||||
?.groups['pid'] ?? null;
|
||||
|
||||
if (!sshAgentSocket || !sshAgentProcessId) {
|
||||
throw new Error('Failed to start ssh-agent')
|
||||
|
|
Loading…
Add table
Reference in a new issue