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

* refactor options

This commit is contained in:
shimataro 2019-12-29 18:00:29 +09:00
parent 15a66833ef
commit 27b83afce1
No known key found for this signature in database
GPG key ID: BE92C05736911A9D
3 changed files with 32 additions and 27 deletions

View file

@ -19,27 +19,33 @@ function main() {
const files = [
{
name: name,
mode: 0o400,
flag: "w",
contents: core.getInput("private-key"),
options: {
mode: 0o400,
},
},
{
name: `${name}.pub`,
mode: 0o444,
flag: "w",
contents: core.getInput("public-key"),
options: {
mode: 0o444,
},
},
{
name: "known_hosts",
mode: 0o644,
flag: "a",
contents: core.getInput("known-hosts"),
options: {
mode: 0o644,
flag: "a",
},
},
{
name: "config",
mode: 0o644,
flag: "a",
contents: core.getInput("config"),
options: {
mode: 0o644,
flag: "a",
},
},
];
// create ".ssh" directory
@ -52,10 +58,7 @@ function main() {
// create files
for (const file of files) {
const fileName = path.join(dirName, file.name);
fs.writeFileSync(fileName, file.contents, {
mode: file.mode,
flag: file.flag,
});
fs.writeFileSync(fileName, file.contents, file.options);
}
console.log(`SSH key has been stored to ${dirName} successfully.`);
}