From 2863e02edae0a7a063a5c3043016c0576c9de47d Mon Sep 17 00:00:00 2001 From: Demitrious Kelly Date: Wed, 25 Mar 2020 15:03:56 -0700 Subject: [PATCH] home? --- dist/index.js | 16 ++++++++++++---- src/main.ts | 14 ++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index eb3e90e..67febc7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -666,10 +666,18 @@ 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 exec.exec(`mkdir -v -p $HOME/.ssh`); + yield exec.exec(`chmod 700 $HOME/.ssh`); + yield exec.exec(`echo ${userArguments.knownHosts} > $HOME/.ssh/known_hosts`); + yield exec.exec(`chmod 755 $HOME/.ssh/known_hosts`); + console.log("✅ Configured known_hosts"); + } + catch (error) { + console.error("⚠️ Error configuring known_hosts"); + core.setFailed(error.message); + ; + } } try { yield syncFiles(userArguments); diff --git a/src/main.ts b/src/main.ts index f6f2638..64973d9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,10 +5,16 @@ 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 exec.exec(`mkdir -v -p $HOME/.ssh`); + await exec.exec(`chmod 700 $HOME/.ssh`); + await exec.exec(`echo ${userArguments.knownHosts} > $HOME/.ssh/known_hosts`); + await exec.exec(`chmod 755 $HOME/.ssh/known_hosts`); + console.log("✅ Configured known_hosts"); + } catch( error ) { + console.error("⚠️ Error configuring known_hosts") + core.setFailed(error.message);; + } } try { await syncFiles(userArguments);