[NAMING] Add *Path suffix where applicable

Signed-off-by: Oktawian Chojnacki <oktawian@me.com>
This commit is contained in:
Oktawian Chojnacki 2022-10-19 12:13:54 +02:00
parent 0a5d1715cf
commit 4b29c05a2e
No known key found for this signature in database
GPG key ID: 19848A5660FCC34A
3 changed files with 14 additions and 14 deletions

View file

@ -1,11 +1,11 @@
const core = require('@actions/core');
const { execFileSync } = require('child_process');
const { sshAgent } = require('./paths.js');
const { sshAgentPath } = require('./paths.js');
try {
// Kill the started SSH agent
console.log('Stopping SSH agent');
execFileSync(sshAgent, ['-k'], { stdio: 'inherit' });
execFileSync(sshAgentPath, ['-k'], { stdio: 'inherit' });
} catch (error) {
console.log(error.message);
console.log('Error stopping the SSH agent, proceeding anyway');

View file

@ -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, gitPath } = require('./paths.js');
const { homePath, sshAgentPath, sshAddPath, gitPath } = require('./paths.js');
try {
const privateKey = core.getInput('ssh-private-key');
@ -13,7 +13,7 @@ try {
return;
}
const homeSsh = home + '/.ssh';
const homeSsh = homePath + '/.ssh';
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
@ -28,7 +28,7 @@ try {
const sshAgentArgs = (authSock && authSock.length > 0) ? ['-a', authSock] : [];
// Extract auth socket path and agent pid and set them as job variables
child_process.execFileSync(sshAgent, sshAgentArgs).toString().split("\n").forEach(function(line) {
child_process.execFileSync(sshAgentPath, sshAgentArgs).toString().split("\n").forEach(function(line) {
const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line);
if (matches && matches.length > 0) {
@ -41,16 +41,16 @@ try {
console.log("Adding private key(s) to agent");
privateKey.split(/(?=-----BEGIN)/).forEach(function(key) {
child_process.execFileSync(sshAdd, ['-'], { input: key.trim() + "\n" });
child_process.execFileSync(sshAddPath, ['-'], { input: key.trim() + "\n" });
});
console.log("Key(s) added:");
child_process.execFileSync(sshAdd, ['-l'], { stdio: 'inherit' });
child_process.execFileSync(sshAddPath, ['-l'], { stdio: 'inherit' });
console.log('Configuring deployment key(s)');
child_process.execFileSync(sshAdd, ['-L']).toString().split(/\r?\n/).forEach(function(key) {
child_process.execFileSync(sshAddPath, ['-L']).toString().split(/\r?\n/).forEach(function(key) {
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i);
if (!parts) {

View file

@ -4,16 +4,16 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
// 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
home: os.userInfo().homedir,
sshAgent: 'ssh-agent',
sshAdd: 'ssh-add',
homePath: os.userInfo().homedir,
sshAgentPath: 'ssh-agent',
sshAddPath: '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',
homePath: os.homedir(),
sshAgentPath: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddPath: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitPath: 'c://progra~1//git//usr//bin//git.exe'
};