From 9315d47124578c43362ac2c80885336da6d660ce Mon Sep 17 00:00:00 2001 From: Demitrious Kelly Date: Wed, 25 Mar 2020 14:52:17 -0700 Subject: [PATCH] attempt to create known_hosts --- dist/index.js | 9 ++++++++- src/main.ts | 10 ++++++++-- src/types.ts | 5 ++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index d40a6ca..eb3e90e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -665,6 +665,12 @@ const exec = __importStar(__webpack_require__(986)); function run() { return __awaiter(this, void 0, void 0, function* () { const userArguments = getUserArguments(); + if ('' !== userArguments.knownHosts) { + yield exec.exec(`mkdir -p /home/runner/.ssh`); + yield exec.exec(`chmod 0700 /home/runner/.ssh`); + yield exec.exec(`echo ${userArguments.knownHosts} > /home/runner/.ssh/known_hosts`); + yield exec.exec(`chmod 0700 /home/runner/.ssh/known_hosts`); + } try { yield syncFiles(userArguments); console.log("✅ Deploy Complete"); @@ -682,7 +688,8 @@ function getUserArguments() { ftp_username: core.getInput("ftp-username", { required: true }), ftp_password: core.getInput("ftp-password", { required: true }), local_dir: withDefault(core.getInput("local-dir"), "./"), - gitFtpArgs: withDefault(core.getInput("git-ftp-args"), "") + gitFtpArgs: withDefault(core.getInput("git-ftp-args"), ""), + knownHosts: withDefault(core.getInput("known-hosts"), "") }; } function withDefault(value, defaultValue) { diff --git a/src/main.ts b/src/main.ts index fbff22f..f6f2638 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,12 @@ import { IActionArguments } from './types'; async function run() { const userArguments = getUserArguments(); - + if ( '' !== userArguments.knownHosts ) { + await exec.exec(`mkdir -p /home/runner/.ssh`); + await exec.exec(`chmod 0700 /home/runner/.ssh`); + await exec.exec(`echo ${userArguments.knownHosts} > /home/runner/.ssh/known_hosts`); + await exec.exec(`chmod 0700 /home/runner/.ssh/known_hosts`); + } try { await syncFiles(userArguments); @@ -25,7 +30,8 @@ function getUserArguments(): IActionArguments { ftp_username: core.getInput("ftp-username", { required: true }), ftp_password: core.getInput("ftp-password", { required: true }), local_dir: withDefault(core.getInput("local-dir"), "./"), - gitFtpArgs: withDefault(core.getInput("git-ftp-args"), "") + gitFtpArgs: withDefault(core.getInput("git-ftp-args"), ""), + knownHosts: withDefault(core.getInput("known-hosts"), "") }; } diff --git a/src/types.ts b/src/types.ts index deb95be..9110ddc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,6 +8,9 @@ export interface IActionArguments { /** @default "" */ gitFtpArgs: string | undefined; + + /** @default "" */ + knownHosts: string | undefined; } /** @@ -25,4 +28,4 @@ export enum gitFTPExitCode { NotAGitProject = 8, PreFTPPushHookFailed = 9, LocalFileOperationFailed = 10 -} \ No newline at end of file +}