mirror of
https://github.com/webfactory/ssh-agent.git
synced 2025-06-27 21:23:46 +00:00
Try to kill the ssh-agent upon action termination on Windows as well
This commit is contained in:
parent
384ccf693f
commit
d57d85f6f9
5 changed files with 82 additions and 42 deletions
10
cleanup.js
10
cleanup.js
|
@ -1,10 +1,12 @@
|
|||
const core = require('@actions/core')
|
||||
const { execSync } = require('child_process')
|
||||
const core = require('@actions/core');
|
||||
const { execSync } = require('child_process');
|
||||
const { sshAgent } = require('./paths.js');
|
||||
|
||||
try {
|
||||
// Kill the started SSH agent
|
||||
console.log('Stopping SSH agent')
|
||||
execSync('kill ${SSH_AGENT_PID}', { stdio: 'inherit' })
|
||||
console.log('Stopping SSH agent');
|
||||
execSync(sshAgent, ['-k'], { stdio: 'inherit' });
|
||||
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
console.log('Error stopping the SSH agent, proceeding anyway');
|
||||
|
|
35
dist/cleanup.js
vendored
35
dist/cleanup.js
vendored
|
@ -122,13 +122,15 @@ module.exports = require("child_process");
|
|||
/***/ 175:
|
||||
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
|
||||
|
||||
const core = __webpack_require__(470)
|
||||
const { execSync } = __webpack_require__(129)
|
||||
const core = __webpack_require__(470);
|
||||
const { execSync } = __webpack_require__(129);
|
||||
const { sshAgent } = __webpack_require__(972);
|
||||
|
||||
try {
|
||||
// Kill the started SSH agent
|
||||
console.log('Stopping SSH agent')
|
||||
execSync('kill ${SSH_AGENT_PID}', { stdio: 'inherit' })
|
||||
console.log('Stopping SSH agent');
|
||||
execSync(sshAgent, ['-k'], { stdio: 'inherit' });
|
||||
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
console.log('Error stopping the SSH agent, proceeding anyway');
|
||||
|
@ -480,6 +482,31 @@ module.exports = require("path");
|
|||
|
||||
module.exports = require("fs");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 972:
|
||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||
|
||||
const os = __webpack_require__(87);
|
||||
|
||||
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'
|
||||
|
||||
} : {
|
||||
|
||||
home: os.homedir(),
|
||||
sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe',
|
||||
sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe'
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
43
dist/index.js
vendored
43
dist/index.js
vendored
|
@ -118,8 +118,8 @@ exports.issueCommand = issueCommand;
|
|||
const core = __webpack_require__(470);
|
||||
const child_process = __webpack_require__(129);
|
||||
const fs = __webpack_require__(747);
|
||||
const os = __webpack_require__(87);
|
||||
const crypto = __webpack_require__(417);
|
||||
const { home, sshAgent, sshAdd } = __webpack_require__(972);
|
||||
|
||||
try {
|
||||
const privateKey = core.getInput('ssh-private-key');
|
||||
|
@ -130,22 +130,6 @@ try {
|
|||
return;
|
||||
}
|
||||
|
||||
const { home, sshAgent, sshAdd } = (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'
|
||||
|
||||
} : {
|
||||
|
||||
home: os.homedir(),
|
||||
sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe',
|
||||
sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe'
|
||||
|
||||
};
|
||||
|
||||
const homeSsh = home + '/.ssh';
|
||||
|
||||
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
|
||||
|
@ -572,6 +556,31 @@ module.exports = require("path");
|
|||
|
||||
module.exports = require("fs");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 972:
|
||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||
|
||||
const os = __webpack_require__(87);
|
||||
|
||||
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'
|
||||
|
||||
} : {
|
||||
|
||||
home: os.homedir(),
|
||||
sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe',
|
||||
sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe'
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
18
index.js
18
index.js
|
@ -1,8 +1,8 @@
|
|||
const core = require('@actions/core');
|
||||
const child_process = require('child_process');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const crypto = require('crypto');
|
||||
const { home, sshAgent, sshAdd } = require('./paths.js');
|
||||
|
||||
try {
|
||||
const privateKey = core.getInput('ssh-private-key');
|
||||
|
@ -13,22 +13,6 @@ try {
|
|||
return;
|
||||
}
|
||||
|
||||
const { home, sshAgent, sshAdd } = (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'
|
||||
|
||||
} : {
|
||||
|
||||
home: os.homedir(),
|
||||
sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe',
|
||||
sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe'
|
||||
|
||||
};
|
||||
|
||||
const homeSsh = home + '/.ssh';
|
||||
|
||||
console.log(`Adding GitHub.com keys to ${homeSsh}/known_hosts`);
|
||||
|
|
18
paths.js
Normal file
18
paths.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const os = require('os');
|
||||
|
||||
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'
|
||||
|
||||
} : {
|
||||
|
||||
home: os.homedir(),
|
||||
sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe',
|
||||
sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe'
|
||||
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue