From bd4da76485504e913df62468103f04819d381dc4 Mon Sep 17 00:00:00 2001 From: Jackz Date: Thu, 12 Dec 2024 22:26:05 -0600 Subject: [PATCH] allow auto extarct --- action.yml | 11 +++++++---- entrypoint.sh | 9 ++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index d2f83ec..afb5784 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,9 @@ -name: 'SCP deploy action' +name: 'SCP Deploy Smart' description: 'Action to send dist files to a remote server with scp command' -author: 'Fabricio Nogueira' +author: 'Fabricio Nogueira & Jackz' inputs: src: - description: 'Sorce dir to deploy' + description: 'Source dir to deploy' required: true host: description: 'SSH address' @@ -14,7 +14,7 @@ inputs: port: description: 'SSH Port' required: false - default: 22 + default: "22" user: description: 'SSH User name' required: true @@ -24,6 +24,9 @@ inputs: options: description: 'Extra options for scp' required: false + extract: + description: 'Is src a tar file to be extracted?' + required: false runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 55efbbb..380c690 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,9 +15,16 @@ echo "Local Path: ${INPUT_SRC}" echo "Remote Path: ${INPUT_REMOTE}" echo "Commit: ${COMMIT_SHA}" +if [[ -z "$INPUT_EXTRACT"]]; then +# SCP normal files scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ -P "${INPUT_PORT}" $INPUT_OPTIONS -r ${INPUT_SRC} "${INPUT_USER}"@"${INPUT_HOST}":"${INPUT_REMOTE}/${COMMIT_SHA}" - +elif +# Untar directly via SSh +ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ + "${INPUT_USER}"@"${INPUT_HOST}" -p "${INPUT_PORT}" \ + -C "mkdir ${INPUT_REMOTE}/${COMMIT_SHA} && cd ${INPUT_REMOTE}/${COMMIT_SHA} && tar -xvv" < $INPUT_SRC +fi echo "File transfer complete. Symlinking and purging old entries" ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ "${INPUT_USER}"@"${INPUT_HOST}" -p "${INPUT_PORT}" \