ssh-agent-action/cleanup.js
Turtle Kalus 83c3be0f44 fix: Add Cmd Default/Input support to cleanup
Bring `post` actions step into consistency with `main` for changes
introduced in #154

Without this change, `sshAgentCmd` is undefined when passed to
`execFileSync()` during `cleanup` and `post` is never successful.
2024-09-24 16:29:07 -07:00

14 lines
548 B
JavaScript

const core = require('@actions/core');
const { execFileSync } = require('child_process');
const { sshAgentCmdDefault } = require('./paths.js');
try {
const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
const sshAgentCmd = sshAgentCmdInput ? sshAgentCmdInput : sshAgentCmdDefault;
// Kill the started SSH agent
console.log('Stopping SSH agent');
execFileSync(sshAgentCmd, ['-k'], { stdio: 'inherit' });
} catch (error) {
console.log(error.message);
console.log('Error stopping the SSH agent, proceeding anyway');
}