mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
add transpiled file
This commit is contained in:
parent
3030f9c5d9
commit
4f9c73a958
1 changed files with 27 additions and 3 deletions
24
lib/index.js
24
lib/index.js
|
@ -2832,10 +2832,15 @@ function setup() {
|
||||||
* cleanup function
|
* cleanup function
|
||||||
*/
|
*/
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
|
if (shouldRemoveSshDirectory()) {
|
||||||
// remove ".ssh" directory
|
// remove ".ssh" directory
|
||||||
const sshDirName = removeSshDirectory();
|
const sshDirName = removeSshDirectory();
|
||||||
console.log(`SSH key in ${sshDirName} has been removed successfully.`);
|
console.log(`SSH key in ${sshDirName} has been removed successfully.`);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
console.log(`Skip directory deletion.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* create ".ssh" directory
|
* create ".ssh" directory
|
||||||
* @returns directory name
|
* @returns directory name
|
||||||
|
@ -2940,6 +2945,25 @@ function shouldCreateKeyFile(keyFilePath, ifKeyExists) {
|
||||||
throw new Error(`SSH key is already installed. Set "if_key_exists" to "replace" or "ignore" in order to avoid this error.`);
|
throw new Error(`SSH key is already installed. Set "if_key_exists" to "replace" or "ignore" in order to avoid this error.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* should remove SSH directory?
|
||||||
|
* @returns Yes/No
|
||||||
|
*/
|
||||||
|
function shouldRemoveSshDirectory() {
|
||||||
|
const keepsSshDir = core.getInput("keep_ssh_dir", {
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
// empty string or falsy value in YAML
|
||||||
|
switch (keepsSshDir.toLowerCase()) {
|
||||||
|
case "":
|
||||||
|
case "false":
|
||||||
|
case "no":
|
||||||
|
case "off":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* build array of known_hosts
|
* build array of known_hosts
|
||||||
* @param knownHosts known_hosts
|
* @param knownHosts known_hosts
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue