From c6d9be15a75e68df5a24db0cbf4978c4ab50ae13 Mon Sep 17 00:00:00 2001 From: JoshPiper <32164094+JoshPiper@users.noreply.github.com> Date: Sun, 5 Jan 2020 11:03:17 +0000 Subject: [PATCH 1/4] Update Dockerfile --- Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9157dd5..e206465 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,7 @@ -FROM alpine:latest - -# Update -RUN apk --update --no-cache add rsync bash openssh-client +FROM drinternet/rsync:1.0.1 # Copy entrypoint -ADD entrypoint.sh /entrypoint.sh +COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] From 0010c2adf64c08b73923a9d465d9e4e4637af7c7 Mon Sep 17 00:00:00 2001 From: JoshPiper <32164094+JoshPiper@users.noreply.github.com> Date: Sun, 5 Jan 2020 11:06:14 +0000 Subject: [PATCH 2/4] Update entrypoint.sh --- entrypoint.sh | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 83ea6d5..af2dd8a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,18 +1,10 @@ -#!/usr/bin/env bash +#!/bin/bash set -eu -# Set deploy key -SSH_PATH="$HOME/.ssh" - -# Create .ssh dir if it doesn't exist -[ -d "$SSH_PATH" ] || mkdir "$SSH_PATH" - -# Place deploy_key into .ssh dir -echo "$INPUT_REMOTE_KEY" > "$SSH_PATH/key" - -# Set r+w to user only -chmod 600 "$SSH_PATH/key" +# Start the SSH agent and load key. +source agent-start "$GITHUB_ACTION" +echo "$INPUT_REMOTE_KEY" | agent-add # Do deployment -sh -c "rsync $INPUT_SWITCHES -e 'ssh -i $SSH_PATH/key -o StrictHostKeyChecking=no -p $INPUT_REMOTE_PORT $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_REMOTE_USER@$INPUT_REMOTE_HOST:$INPUT_REMOTE_PATH" +sh -c "rsync $INPUT_SWITCHES -e 'ssh -o StrictHostKeyChecking=no -p $INPUT_REMOTE_PORT $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_REMOTE_USER@$INPUT_REMOTE_HOST:$INPUT_REMOTE_PATH" From c5464e03ed2294d11af7cf9f9af7be3fb02cc919 Mon Sep 17 00:00:00 2001 From: JoshPiper <32164094+JoshPiper@users.noreply.github.com> Date: Sun, 5 Jan 2020 11:11:59 +0000 Subject: [PATCH 3/4] Use sh not bash. --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index af2dd8a..2a2ff39 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -eu From 9f59b515f6bac904231e6c5faa4897295b3b7a0e Mon Sep 17 00:00:00 2001 From: JoshPiper <32164094+JoshPiper@users.noreply.github.com> Date: Sun, 5 Jan 2020 11:19:21 +0000 Subject: [PATCH 4/4] Update entrypoint.sh --- entrypoint.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2a2ff39..a95b8b0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,9 @@ #!/bin/sh -set -eu - # Start the SSH agent and load key. source agent-start "$GITHUB_ACTION" echo "$INPUT_REMOTE_KEY" | agent-add -# Do deployment +# Add strict errors and deploy. +set -eu sh -c "rsync $INPUT_SWITCHES -e 'ssh -o StrictHostKeyChecking=no -p $INPUT_REMOTE_PORT $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_REMOTE_USER@$INPUT_REMOTE_HOST:$INPUT_REMOTE_PATH"