Skip to content

Commit 7aec9dc

Browse files
committed
Consider custom command name inputs in cleanup.js
1 parent dc588b6 commit 7aec9dc

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

cleanup.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const core = require('@actions/core');
21
const { execFileSync } = require('child_process');
32
const { sshAgentCmd } = require('./paths.js');
43

index.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@ const core = require('@actions/core');
22
const child_process = require('child_process');
33
const fs = require('fs');
44
const crypto = require('crypto');
5-
const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = require('./paths.js');
5+
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = require('./paths.js');
66

77
try {
88
const privateKey = core.getInput('ssh-private-key');
99
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
1010

11-
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
12-
const sshAddCmdInput = core.getInput('ssh-add-cmd');
13-
const gitCmdInput = core.getInput('git-cmd');
14-
15-
const sshAgentCmd = sshAgentCmdInput ? sshAgentCmdInput : sshAgentCmdDefault;
16-
const sshAddCmd = sshAddCmdInput ? sshAddCmdInput : sshAddCmdDefault;
17-
const gitCmd = gitCmdInput ? gitCmdInput : gitCmdDefault;
18-
1911
if (!privateKey) {
2012
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.");
2113

paths.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const os = require('os');
2+
const core = require('@actions/core');
23

3-
module.exports = (process.env['OS'] != 'Windows_NT') ? {
4+
const defaults = (process.env['OS'] != 'Windows_NT') ? {
45
// Use getent() system call, since this is what ssh does; makes a difference in Docker-based
56
// Action runs, where $HOME is different from the pwent
67
homePath: os.userInfo().homedir,
@@ -14,3 +15,14 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
1415
sshAddCmdDefault: 'c://progra~1//git//usr//bin//ssh-add.exe',
1516
gitCmdDefault: 'c://progra~1//git//bin//git.exe'
1617
};
18+
19+
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
20+
const sshAddCmdInput = core.getInput('ssh-add-cmd');
21+
const gitCmdInput = core.getInput('git-cmd');
22+
23+
module.exports = {
24+
homePath: defaults.homePath,
25+
sshAgentCmd: sshAgentCmdInput !== '' ? sshAgentCmdInput : defaults.sshAgentCmdDefault,
26+
sshAddCmd: sshAddCmdInput !== '' ? sshAddCmdInput : defaults.sshAddCmdDefault,
27+
gitCmd: gitCmdInput !== '' ? gitCmdInput : defaults.gitCmdDefault,
28+
};

0 commit comments

Comments
 (0)