diff --git a/index.js b/index.js index e08d46f..1635da2 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ const core = require('@actions/core'); const child_process = require('child_process'); const fs = require('fs'); const crypto = require('crypto'); -const { home, sshAgent, sshAdd } = require('./paths.js'); +const { home, sshAgent, sshAdd, gitPath } = require('./paths.js'); try { const privateKey = core.getInput('ssh-private-key'); @@ -64,9 +64,9 @@ try { fs.writeFileSync(`${homeSsh}/key-${sha256}`, key + "\n", { mode: '600' }); - child_process.execSync(`git config --global --replace-all url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "https://github.com/${ownerAndRepo}"`); - child_process.execSync(`git config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "git@github.com:${ownerAndRepo}"`); - child_process.execSync(`git config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "ssh://git@github.com/${ownerAndRepo}"`); + child_process.execSync(`${gitPath} config --global --replace-all url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "https://github.com/${ownerAndRepo}"`); + child_process.execSync(`${gitPath} config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "git@github.com:${ownerAndRepo}"`); + child_process.execSync(`${gitPath} config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "ssh://git@github.com/${ownerAndRepo}"`); const sshConfig = `\nHost key-${sha256}.github.com\n` + ` HostName github.com\n` diff --git a/paths.js b/paths.js index 8ee7afd..51ff4b6 100644 --- a/paths.js +++ b/paths.js @@ -6,13 +6,14 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? { // Action runs, where $HOME is different from the pwent home: os.userInfo().homedir, sshAgent: 'ssh-agent', - sshAdd: 'ssh-add' + sshAdd: 'ssh-add', + gitPath: 'git' } : { home: os.homedir(), sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe', - sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe' - + sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe', + gitPath: 'c://progra~1//git//usr//bin//git.exe' };