diff options
| author | eric sciple <ericsciple@users.noreply.github.com> | 2020-03-11 19:18:07 -0400 |
|---|---|---|
| committer | eric sciple <ericsciple@users.noreply.github.com> | 2020-03-11 19:18:07 -0400 |
| commit | 102e8f7bbdbd4f0df12cee6ac817816a8240ab97 (patch) | |
| tree | caa9eba1e1106c7756445054ed97a98f05c5b4c9 /dist | |
| parent | 1b406b27feed694fb3a05a638c92124514baa6ea (diff) | |
persist core.sshCommand for submodules
Diffstat (limited to 'dist')
| -rw-r--r-- | dist/index.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/dist/index.js b/dist/index.js index 706f035..c7f2bca 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5122,6 +5122,7 @@ class GitAuthHelper { this.tokenConfigKey = `http.https://${HOSTNAME}/.extraheader`; this.insteadOfKey = `url.https://${HOSTNAME}/.insteadOf`; this.insteadOfValue = `git@${HOSTNAME}:`; + this.sshCommand = ''; this.sshKeyPath = ''; this.sshKnownHostsPath = ''; this.temporaryHomePath = ''; @@ -5205,8 +5206,12 @@ class GitAuthHelper { core.debug(`Replacing token placeholder in '${configPath}'`); this.replaceTokenPlaceholder(configPath); } - // Configure HTTPS instead of SSH - if (!this.settings.sshKey) { + if (this.settings.sshKey) { + // Configure core.sshCommand + yield this.git.submoduleForeach(`git config --local '${SSH_COMMAND_KEY}' '${this.sshCommand}'`, this.settings.nestedSubmodules); + } + else { + // Configure HTTPS instead of SSH yield this.git.submoduleForeach(`git config --local '${this.insteadOfKey}' '${this.insteadOfValue}'`, this.settings.nestedSubmodules); } } @@ -5268,16 +5273,16 @@ class GitAuthHelper { yield fs.promises.writeFile(this.sshKnownHostsPath, knownHosts); // Configure GIT_SSH_COMMAND const sshPath = yield io.which('ssh', true); - let sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(this.sshKeyPath)}"`; + this.sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(this.sshKeyPath)}"`; if (this.settings.sshStrict) { - sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no'; + this.sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no'; } - sshCommand += ` -o "UserKnownHostsFile=$RUNNER_TEMP/${path.basename(this.sshKnownHostsPath)}"`; - core.info(`Temporarily overriding GIT_SSH_COMMAND=${sshCommand}`); - this.git.setEnvironmentVariable('GIT_SSH_COMMAND', sshCommand); + this.sshCommand += ` -o "UserKnownHostsFile=$RUNNER_TEMP/${path.basename(this.sshKnownHostsPath)}"`; + core.info(`Temporarily overriding GIT_SSH_COMMAND=${this.sshCommand}`); + this.git.setEnvironmentVariable('GIT_SSH_COMMAND', this.sshCommand); // Configure core.sshCommand if (this.settings.persistCredentials) { - yield this.git.config(SSH_COMMAND_KEY, sshCommand); + yield this.git.config(SSH_COMMAND_KEY, this.sshCommand); } }); } |
