mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-04-23 22:50:47 +00:00
Consider custom command name inputs in cleanup.js
This commit is contained in:
parent
b504c19775
commit
3c2bfbcad6
3 changed files with 14 additions and 11 deletions
|
@ -1,4 +1,3 @@
|
||||||
const core = require('@actions/core');
|
|
||||||
const { execFileSync } = require('child_process');
|
const { execFileSync } = require('child_process');
|
||||||
const { sshAgentCmd } = require('./paths.js');
|
const { sshAgentCmd } = require('./paths.js');
|
||||||
|
|
||||||
|
|
10
index.js
10
index.js
|
@ -2,20 +2,12 @@ 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, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = require('./paths.js');
|
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = 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.");
|
||||||
|
|
||||||
|
|
14
paths.js
14
paths.js
|
@ -1,6 +1,7 @@
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
|
||||||
module.exports = (process.env['OS'] != 'Windows_NT') ? {
|
const defaults = (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,
|
||||||
|
@ -14,3 +15,14 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
|
||||||
sshAddCmdDefault: 'c://progra~1//git//usr//bin//ssh-add.exe',
|
sshAddCmdDefault: 'c://progra~1//git//usr//bin//ssh-add.exe',
|
||||||
gitCmdDefault: 'c://progra~1//git//bin//git.exe'
|
gitCmdDefault: 'c://progra~1//git//bin//git.exe'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
|
||||||
|
const sshAddCmdInput = core.getInput('ssh-add-cmd');
|
||||||
|
const gitCmdInput = core.getInput('git-cmd');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
homePath: defaults.homePath,
|
||||||
|
sshAgentCmd: sshAgentCmdInput !== '' ? sshAgentCmdInput : defaults.sshAgentCmdDefault,
|
||||||
|
sshAddCmd: sshAddCmdInput !== '' ? sshAddCmdInput : defaults.sshAddCmdDefault,
|
||||||
|
gitCmd: gitCmdInput !== '' ? gitCmdInput : defaults.gitCmdDefault,
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue