From 4f9c73a9587fa514ca9288d19dbb6b76d1035367 Mon Sep 17 00:00:00 2001 From: shimataro Date: Mon, 9 Oct 2023 18:36:30 +0900 Subject: [PATCH] add transpiled file --- lib/index.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 16492d5..7f9f21b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2832,9 +2832,14 @@ function setup() { * cleanup function */ function cleanup() { - // remove ".ssh" directory - const sshDirName = removeSshDirectory(); - console.log(`SSH key in ${sshDirName} has been removed successfully.`); + if (shouldRemoveSshDirectory()) { + // remove ".ssh" directory + const sshDirName = removeSshDirectory(); + console.log(`SSH key in ${sshDirName} has been removed successfully.`); + } + else { + console.log(`Skip directory deletion.`); + } } /** * create ".ssh" directory @@ -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.`); } } +/** + * 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 * @param knownHosts known_hosts