1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-19 22:52:10 +10:00

Feature/GitHub key (#122)

* always prepend key of github.com

* update README and CHANGELOG

* update tests

* test to connect bitbucket.org

* update test

* update rest tests
This commit is contained in:
shimataro 2022-11-03 03:41:25 +09:00 committed by GitHub
parent bcb314ec07
commit 1512adeca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 644 additions and 255 deletions

View file

@ -2723,6 +2723,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const fs_1 = __importDefault(__nccwpck_require__(147));
const path_1 = __importDefault(__nccwpck_require__(17));
const core = __importStar(__nccwpck_require__(186));
const KNOWN_HOSTS = [
"github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==",
];
try {
main();
}
@ -2748,7 +2751,16 @@ function main() {
// create ".ssh" directory
const sshDirName = createSshDirectory();
// files to be created
const files = [];
const files = [
{
name: "known_hosts",
contents: insertLf(buildKnownHostsArray(knownHosts).join("\n"), true, true),
options: {
mode: 0o644,
flag: "a",
},
},
];
if (shouldCreateKeyFile(path_1.default.join(sshDirName, name), ifKeyExists)) {
files.push({
name: name,
@ -2759,16 +2771,6 @@ function main() {
},
});
}
if (knownHosts !== "unnecessary") {
files.push({
name: "known_hosts",
contents: insertLf(knownHosts, true, true),
options: {
mode: 0o644,
flag: "a",
},
});
}
if (config !== "") {
files.push({
name: "config",
@ -2872,6 +2874,17 @@ 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.`);
}
}
/**
* build array of known_hosts
* @param knownHosts known_hosts
* @returns array of known_hosts
*/
function buildKnownHostsArray(knownHosts) {
if (knownHosts === "unnecessary") {
return KNOWN_HOSTS;
}
return KNOWN_HOSTS.concat(knownHosts);
}
/***/ }),