Skip to content

Commit

Permalink
Fix home dir detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Feb 4, 2020
1 parent e7e7ec8 commit b3b3216
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const fs = __webpack_require__(747);
try {
const os = process.env['OS'];
const privateKey = core.getInput('ssh-private-key').trim();
var home, homeSsh;

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.");
Expand All @@ -71,12 +72,12 @@ try {
console.log('Preparing ssh-agent service on Windows');
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });

const home = process.env['HOMEDRIVE'] + process.env['HOMEPATH'];
home = process.env['HOMEDRIVE'] + process.env['HOMEPATH'];
} else {
const home = process.env['HOME'];
home = process.env['HOME'];
}

const homeSsh = home + '/.ssh';
homeSsh = home + '/.ssh';

console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
fs.mkdirSync(homeSsh, { recursive: true});
Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require('fs');
try {
const os = process.env['OS'];
const privateKey = core.getInput('ssh-private-key').trim();
var home, homeSsh;

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.");
Expand All @@ -16,12 +17,12 @@ try {
console.log('Preparing ssh-agent service on Windows');
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });

const home = process.env['HOMEDRIVE'] + process.env['HOMEPATH'];
home = process.env['HOMEDRIVE'] + process.env['HOMEPATH'];
} else {
const home = process.env['HOME'];
home = process.env['HOME'];
}

const homeSsh = home + '/.ssh';
homeSsh = home + '/.ssh';

console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
fs.mkdirSync(homeSsh, { recursive: true});
Expand Down

0 comments on commit b3b3216

Please sign in to comment.