mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-06-30 22:53:46 +00:00
Merge fe90c7bf94
into a6f90b1f12
This commit is contained in:
commit
4779a3f805
4 changed files with 28 additions and 12 deletions
18
dist/index.js
vendored
18
dist/index.js
vendored
|
@ -325,6 +325,11 @@ const crypto = __webpack_require__(417);
|
|||
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = __webpack_require__(972);
|
||||
|
||||
try {
|
||||
const instanceURL = core.getInput('instance-url') || process.env.GITHUB_SERVER_URL || 'https://github.com';
|
||||
const instanceDomain = instanceURL.replace(/^https?:\/\//, '');
|
||||
const escapedDomain = instanceDomain.replace(/[-.]/g, '\\$&');
|
||||
const regexDomain = new RegExp(`\\b${escapedDomain}[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)`, 'i');
|
||||
|
||||
const privateKey = core.getInput('ssh-private-key');
|
||||
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
|
||||
|
||||
|
@ -366,7 +371,8 @@ try {
|
|||
console.log('Configuring deployment key(s)');
|
||||
|
||||
child_process.execFileSync(sshAddCmd, ['-L']).toString().trim().split(/\r?\n/).forEach(function(key) {
|
||||
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i);
|
||||
console.log('Instance domain is:', instanceDomain);
|
||||
const parts = key.match(regexDomain);
|
||||
|
||||
if (!parts) {
|
||||
if (logPublicKey) {
|
||||
|
@ -380,12 +386,12 @@ try {
|
|||
|
||||
fs.writeFileSync(`${homeSsh}/key-${sha256}`, key + "\n", { mode: '600' });
|
||||
|
||||
child_process.execSync(`${gitCmd} config --global --replace-all url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "https://github.com/${ownerAndRepo}"`);
|
||||
child_process.execSync(`${gitCmd} config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "git@github.com:${ownerAndRepo}"`);
|
||||
child_process.execSync(`${gitCmd} config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "ssh://git@github.com/${ownerAndRepo}"`);
|
||||
child_process.execSync(`${gitCmd} config --global --replace-all url."git@key-${sha256}.${instanceDomain}:${ownerAndRepo}".insteadOf "https://${instanceDomain}/${ownerAndRepo}"`);
|
||||
child_process.execSync(`${gitCmd} config --global --add url."git@key-${sha256}.${instanceDomain}:${ownerAndRepo}".insteadOf "git@${instanceDomain}:${ownerAndRepo}"`);
|
||||
child_process.execSync(`${gitCmd} config --global --add url."git@key-${sha256}.${instanceDomain}:${ownerAndRepo}".insteadOf "ssh://git@${instanceDomain}/${ownerAndRepo}"`);
|
||||
|
||||
const sshConfig = `\nHost key-${sha256}.github.com\n`
|
||||
+ ` HostName github.com\n`
|
||||
const sshConfig = `\nHost key-${sha256}.${instanceDomain}\n`
|
||||
+ ` HostName ${instanceDomain}\n`
|
||||
+ ` IdentityFile ${homeSsh}/key-${sha256}\n`
|
||||
+ ` IdentitiesOnly yes\n`;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue