Skip to content

Commit 6d285f5

Browse files
committed
Try different home dir detection as suggested in #38
1 parent 780d0ee commit 6d285f5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: dist/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ exports.issueCommand = issueCommand;
118118
const core = __webpack_require__(470);
119119
const child_process = __webpack_require__(129);
120120
const fs = __webpack_require__(747);
121+
const os = __webpack_require__(87);
121122

122123
try {
123124

124-
const home = process.env['HOME'];
125+
const home = os.homedir();
125126
const homeSsh = home + '/.ssh';
126-
127127
const privateKey = core.getInput('ssh-private-key');
128128

129129
if (!privateKey) {
@@ -132,6 +132,11 @@ try {
132132
return;
133133
}
134134

135+
if (process.env['OS'] == 'Windows_NT') {
136+
console.log('Preparing ssh-agent service on Windows');
137+
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });
138+
}
139+
135140
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
136141
fs.mkdirSync(homeSsh, { recursive: true });
137142
fs.appendFileSync(`${homeSsh}/known_hosts`, '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n');

Diff for: index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const core = require('@actions/core');
22
const child_process = require('child_process');
33
const fs = require('fs');
4+
const os = require('os');
45

56
try {
67

7-
const home = process.env['HOME'];
8+
const home = os.homedir();
89
const homeSsh = home + '/.ssh';
9-
1010
const privateKey = core.getInput('ssh-private-key');
1111

1212
if (!privateKey) {
@@ -15,6 +15,11 @@ try {
1515
return;
1616
}
1717

18+
if (process.env['OS'] == 'Windows_NT') {
19+
console.log('Preparing ssh-agent service on Windows');
20+
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });
21+
}
22+
1823
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
1924
fs.mkdirSync(homeSsh, { recursive: true });
2025
fs.appendFileSync(`${homeSsh}/known_hosts`, '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n');

0 commit comments

Comments
 (0)