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

Feature/append config known hosts (#47)

* * append to "config" and "known_hosts" instead of overwriting

* * refactor options

* * add test

* * fix test

* * print created files twice

* * print the contents of known_hosts and config

* * fix revision for test

* * fix revision

* * add LF to known_hosts / config

* * append LF to config and known_hosts

* * fix test

* * reject overwriting private-key and public-key

* * update test (will cause error)

* * revert verify.yml

* * update README and CHANGELOG

* * fix example in README

* * update CHANGELOG
This commit is contained in:
shimataro 2019-12-30 08:24:22 +09:00 committed by GitHub
parent 3e015c8816
commit 0374d240c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 20 deletions

View file

@ -6,8 +6,8 @@ import * as core from "@actions/core";
interface FileInfo
{
name: string;
mode: number;
contents: string;
options: fs.WriteFileOptions;
}
/**
@ -21,23 +21,35 @@ function main(): void
const files: FileInfo[] = [
{
name: name,
mode: 0o400,
contents: core.getInput("private-key"),
options: {
mode: 0o400,
flag: "ax",
},
},
{
name: `${name}.pub`,
mode: 0o444,
contents: core.getInput("public-key"),
options: {
mode: 0o444,
flag: "ax",
},
},
{
name: "known_hosts",
mode: 0o644,
contents: core.getInput("known-hosts"),
contents: core.getInput("known-hosts") + "\n",
options: {
mode: 0o644,
flag: "a",
},
},
{
name: "config",
mode: 0o644,
contents: core.getInput("config"),
contents: core.getInput("config") + "\n",
options: {
mode: 0o644,
flag: "a",
},
},
];
@ -53,9 +65,7 @@ function main(): void
for(const file of files)
{
const fileName = path.join(dirName, file.name);
fs.writeFileSync(fileName, file.contents, {
mode: file.mode,
});
fs.writeFileSync(fileName, file.contents, file.options);
}
console.log(`SSH key has been stored to ${dirName} successfully.`);