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:
parent
15a66833ef
commit
27b83afce1
3 changed files with 32 additions and 27 deletions
27
lib/main.js
27
lib/main.js
|
@ -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.`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue