diff --git a/src/executor/runner.js b/src/executor/runner.js index 136a4f1..da875ad 100644 --- a/src/executor/runner.js +++ b/src/executor/runner.js @@ -733,15 +733,13 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec, url.hash = ''; } if (source.credentials?.github?.ssh) { - const filename = '~/.ssh/id_github_com'; - const configFileContent = `Host github.com\n\tStrictHostKeyChecking no\n\tIdentityFile ${filename}\n`; + const configFileContent = `Host github.com\n\tStrictHostKeyChecking no\n\tIdentityFile ~/.ssh/id_github_com\n`; await writeLog("$> writing SSH private key for cloning github.com repository"); - await sshExec(`mkdir -p ~/.ssh`); - await sshExec(`echo "${Buffer.from(source.credentials.github.ssh).toString('base64')}" | base64 --decode > "${filename}"`, true); + await sshExec(`mkdir -p ~/.ssh; touch $HOME/.ssh/{id_github_com,config}; chmod 0600 $HOME/.ssh/*`); + await sshExec(`echo "${Buffer.from(source.credentials.github.ssh).toString('base64')}" | base64 --decode > $HOME/.ssh/config`, true); // delete old config https://stackoverflow.com/a/36111659/3908409 - await sshExec(`sed 's/^Host/\\n&/' ~/.ssh/config | sed '/^Host '"github.com"'$/,/^$/d;/^$/d' > ~/.ssh/config`, true); + await sshExec(`sed 's/^Host/\\n&/' $HOME/.ssh/config | sed '/^Host '"github.com"'$/,/^$/d;/^$/d' > $HOME/.ssh/config`, true); await sshExec(`echo "${Buffer.from(configFileContent).toString('base64')}" | base64 --decode >> ~/.ssh/config`, true); - await sshExec(`chmod 0600 $HOME/.ssh/{id_github_com,config}`, true); } executedCMD.push(`git clone ${escapeShell(url.toString())}` + `${source.branch ? ` -b ${escapeShell(source.branch)}` : ''}` +