Allow the user to override the commands for git, ssh-agent, and ssh-add

This commit is contained in:
Dilum Aluthge 2022-11-30 23:58:28 -05:00
parent 209e2d72ff
commit 1d64dd4577
5 changed files with 45 additions and 20 deletions

View file

@ -10,6 +10,15 @@ inputs:
description: 'Whether or not to log public key fingerprints' description: 'Whether or not to log public key fingerprints'
required: false required: false
default: true default: true
ssh-agent-cmd:
description: 'ssh-agent command'
required: false
ssh-add-cmd:
description: 'ssh-add command'
required: false
git-cmd:
description: 'git command'
required: false
runs: runs:
using: 'node16' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'

12
dist/cleanup.js vendored
View file

@ -2827,15 +2827,15 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
// Use getent() system call, since this is what ssh does; makes a difference in Docker-based // Use getent() system call, since this is what ssh does; makes a difference in Docker-based
// Action runs, where $HOME is different from the pwent // Action runs, where $HOME is different from the pwent
homePath: os.userInfo().homedir, homePath: os.userInfo().homedir,
sshAgentCmd: 'ssh-agent', sshAgentCmdDefault: 'ssh-agent',
sshAddCmd: 'ssh-add', sshAddCmdDefault: 'ssh-add',
gitCmd: 'git' gitCmdDefault: 'git'
} : { } : {
// Assuming GitHub hosted `windows-*` runners for now // Assuming GitHub hosted `windows-*` runners for now
homePath: os.homedir(), homePath: os.homedir(),
sshAgentCmd: 'c://progra~1//git//usr//bin//ssh-agent.exe', sshAgentCmdDefault: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddCmd: 'c://progra~1//git//usr//bin//ssh-add.exe', sshAddCmdDefault: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitCmd: 'c://progra~1//git//bin//git.exe' gitCmdDefault: 'c://progra~1//git//bin//git.exe'
}; };

22
dist/index.js vendored
View file

@ -322,12 +322,20 @@ const core = __webpack_require__(470);
const child_process = __webpack_require__(129); const child_process = __webpack_require__(129);
const fs = __webpack_require__(747); const fs = __webpack_require__(747);
const crypto = __webpack_require__(417); const crypto = __webpack_require__(417);
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = __webpack_require__(972); const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = __webpack_require__(972);
try { try {
const privateKey = core.getInput('ssh-private-key'); const privateKey = core.getInput('ssh-private-key');
const logPublicKey = core.getBooleanInput('log-public-key', {default: true}); const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
const sshAddCmdInput = core.getInput('ssh-add-cmd');
const gitCmdInput = core.getInput('git-cmd');
const sshAgentCmd = sshAgentCmdInput ? sshAgentCmdInput : sshAgentCmdDefault
const sshAddCmd = sshAddCmdInput ? sshAddCmdInput : sshAddCmdDefault
const gitCmd = gitCmdInput ? gitCmdInput : gitCmdDefault
if (!privateKey) { if (!privateKey) {
core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file."); core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file.");
@ -2906,15 +2914,15 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
// Use getent() system call, since this is what ssh does; makes a difference in Docker-based // Use getent() system call, since this is what ssh does; makes a difference in Docker-based
// Action runs, where $HOME is different from the pwent // Action runs, where $HOME is different from the pwent
homePath: os.userInfo().homedir, homePath: os.userInfo().homedir,
sshAgentCmd: 'ssh-agent', sshAgentCmdDefault: 'ssh-agent',
sshAddCmd: 'ssh-add', sshAddCmdDefault: 'ssh-add',
gitCmd: 'git' gitCmdDefault: 'git'
} : { } : {
// Assuming GitHub hosted `windows-*` runners for now // Assuming GitHub hosted `windows-*` runners for now
homePath: os.homedir(), homePath: os.homedir(),
sshAgentCmd: 'c://progra~1//git//usr//bin//ssh-agent.exe', sshAgentCmdDefault: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddCmd: 'c://progra~1//git//usr//bin//ssh-add.exe', sshAddCmdDefault: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitCmd: 'c://progra~1//git//bin//git.exe' gitCmdDefault: 'c://progra~1//git//bin//git.exe'
}; };

View file

@ -2,12 +2,20 @@ const core = require('@actions/core');
const child_process = require('child_process'); const child_process = require('child_process');
const fs = require('fs'); const fs = require('fs');
const crypto = require('crypto'); const crypto = require('crypto');
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = require('./paths.js'); const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = require('./paths.js');
try { try {
const privateKey = core.getInput('ssh-private-key'); const privateKey = core.getInput('ssh-private-key');
const logPublicKey = core.getBooleanInput('log-public-key', {default: true}); const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
const sshAddCmdInput = core.getInput('ssh-add-cmd');
const gitCmdInput = core.getInput('git-cmd');
const sshAgentCmd = sshAgentCmdInput ? sshAgentCmdInput : sshAgentCmdDefault
const sshAddCmd = sshAddCmdInput ? sshAddCmdInput : sshAddCmdDefault
const gitCmd = gitCmdInput ? gitCmdInput : gitCmdDefault
if (!privateKey) { if (!privateKey) {
core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file."); core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file.");

View file

@ -4,13 +4,13 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
// Use getent() system call, since this is what ssh does; makes a difference in Docker-based // Use getent() system call, since this is what ssh does; makes a difference in Docker-based
// Action runs, where $HOME is different from the pwent // Action runs, where $HOME is different from the pwent
homePath: os.userInfo().homedir, homePath: os.userInfo().homedir,
sshAgentCmd: 'ssh-agent', sshAgentCmdDefault: 'ssh-agent',
sshAddCmd: 'ssh-add', sshAddCmdDefault: 'ssh-add',
gitCmd: 'git' gitCmdDefault: 'git'
} : { } : {
// Assuming GitHub hosted `windows-*` runners for now // Assuming GitHub hosted `windows-*` runners for now
homePath: os.homedir(), homePath: os.homedir(),
sshAgentCmd: 'c://progra~1//git//usr//bin//ssh-agent.exe', sshAgentCmdDefault: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddCmd: 'c://progra~1//git//usr//bin//ssh-add.exe', sshAddCmdDefault: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitCmd: 'c://progra~1//git//bin//git.exe' gitCmdDefault: 'c://progra~1//git//bin//git.exe'
}; };