Skip to content

Commit

Permalink
Update runner.js
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Aug 21, 2023
1 parent 648eedf commit df9b859
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/executor/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}` : ''}` +
Expand Down

0 comments on commit df9b859

Please sign in to comment.