mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-04-23 22:50:47 +00:00
Try different home dir detection as suggested in #38
This commit is contained in:
parent
780d0ee9a3
commit
6d285f5b6b
2 changed files with 14 additions and 4 deletions
9
dist/index.js
vendored
9
dist/index.js
vendored
|
@ -118,12 +118,12 @@ exports.issueCommand = issueCommand;
|
||||||
const core = __webpack_require__(470);
|
const core = __webpack_require__(470);
|
||||||
const child_process = __webpack_require__(129);
|
const child_process = __webpack_require__(129);
|
||||||
const fs = __webpack_require__(747);
|
const fs = __webpack_require__(747);
|
||||||
|
const os = __webpack_require__(87);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const home = process.env['HOME'];
|
const home = os.homedir();
|
||||||
const homeSsh = home + '/.ssh';
|
const homeSsh = home + '/.ssh';
|
||||||
|
|
||||||
const privateKey = core.getInput('ssh-private-key');
|
const privateKey = core.getInput('ssh-private-key');
|
||||||
|
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
|
@ -132,6 +132,11 @@ try {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env['OS'] == 'Windows_NT') {
|
||||||
|
console.log('Preparing ssh-agent service on Windows');
|
||||||
|
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
|
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
|
||||||
fs.mkdirSync(homeSsh, { recursive: true });
|
fs.mkdirSync(homeSsh, { recursive: true });
|
||||||
fs.appendFileSync(`${homeSsh}/known_hosts`, '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n');
|
fs.appendFileSync(`${homeSsh}/known_hosts`, '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n');
|
||||||
|
|
9
index.js
9
index.js
|
@ -1,12 +1,12 @@
|
||||||
const core = require('@actions/core');
|
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 os = require('os');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const home = process.env['HOME'];
|
const home = os.homedir();
|
||||||
const homeSsh = home + '/.ssh';
|
const homeSsh = home + '/.ssh';
|
||||||
|
|
||||||
const privateKey = core.getInput('ssh-private-key');
|
const privateKey = core.getInput('ssh-private-key');
|
||||||
|
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
|
@ -15,6 +15,11 @@ try {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env['OS'] == 'Windows_NT') {
|
||||||
|
console.log('Preparing ssh-agent service on Windows');
|
||||||
|
child_process.execSync('sc config ssh-agent start=demand', { stdio: 'inherit' });
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
|
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
|
||||||
fs.mkdirSync(homeSsh, { recursive: true });
|
fs.mkdirSync(homeSsh, { recursive: true });
|
||||||
fs.appendFileSync(`${homeSsh}/known_hosts`, '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n');
|
fs.appendFileSync(`${homeSsh}/known_hosts`, '\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n');
|
||||||
|
|
Loading…
Add table
Reference in a new issue