From 614178c12476d0d49fa3f8e38bb4f5b88e61ac9f Mon Sep 17 00:00:00 2001 From: Fabricio Nogueira Date: Fri, 5 Jun 2020 18:29:58 -0300 Subject: [PATCH 01/22] refactor(docker): Reduce docker image final size --- .dockerignore | 5 +++++ .gitignore | 3 ++- Dockerfile | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0b99357 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +* +*./* +*/* +*.* +!*.sh \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1c36090..c925794 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .history -.vscode \ No newline at end of file +.vscode +*.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index af66730..04648da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ FROM alpine:3.10 -COPY LICENSE README.md / +RUN apk upgrade --update \ + apk add --no-cache openssh \ + && rm -rf /tmp/* /usr/share/man /var/cache/apk/* -COPY entrypoint.sh /entrypoint.sh +COPY . / ENTRYPOINT ["/entrypoint.sh"] From 1d25b00c269657427de491e67069a5dd1b0b0252 Mon Sep 17 00:00:00 2001 From: Fabricio Nogueira Date: Fri, 5 Jun 2020 18:48:26 -0300 Subject: [PATCH 02/22] fix(docker): Fix install scp command in container --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 04648da..b1ad660 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.10 RUN apk upgrade --update \ - apk add --no-cache openssh \ + && apk add --update openssh \ && rm -rf /tmp/* /usr/share/man /var/cache/apk/* COPY . / From ad4ef26acf80833570bc106a3bf1f3ccf3a829e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Kadi=C4=87?= <42221975+nikolakadic@users.noreply.github.com> Date: Thu, 5 Nov 2020 15:36:21 +0100 Subject: [PATCH 03/22] Typo fix :) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 674bbd3..9006d22 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Action to send dist files to a remote server with scp command ## Required params -- `src`: Sorce dir to deploy +- `src`: Source dir to deploy - `host`: SSH address - `remote`: Remote dir path - `port`: SSH Port @@ -59,4 +59,4 @@ jobs: port: ${{ secrets.SSH_PORT }} user: ${{ secrets.SSH_USER }} key: ${{ secrets.SSH_KEY }} -``` \ No newline at end of file +``` From 08d0e7cde130c9f172e5467c56cda92112ed8cbe Mon Sep 17 00:00:00 2001 From: Herman verschooten Date: Thu, 6 May 2021 19:03:27 +0200 Subject: [PATCH 04/22] Add parameter for extra options --- README.md | 1 + action.yml | 5 ++++- entrypoint.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9006d22..f1c1ace 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Action to send dist files to a remote server with scp command - `port`: SSH Port - `user`: SSH User name - `key`: Private key +- `options` : Extra options for scp ### To publish diff --git a/action.yml b/action.yml index c131555..5f4ff64 100644 --- a/action.yml +++ b/action.yml @@ -21,9 +21,12 @@ inputs: key: description: 'Private key' required: true + options: + description: 'Extra options for scp' + required: false runs: using: 'docker' image: 'Dockerfile' branding: icon: 'upload-cloud' - color: 'blue' \ No newline at end of file + color: 'blue' diff --git a/entrypoint.sh b/entrypoint.sh index cc1f436..3a16525 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,4 +4,4 @@ echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE chmod 600 __TEMP_INPUT_KEY_FILE -scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "${INPUT_PORT}" -r ${INPUT_SRC} "${INPUT_USER}"@"${INPUT_HOST}":"${INPUT_REMOTE}" +scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "${INPUT_PORT}" $INPUT_OPTIONS -r ${INPUT_SRC} "${INPUT_USER}"@"${INPUT_HOST}":"${INPUT_REMOTE}" From c4ecacfccb5d5a63400c279b95287d0bd46903f4 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 18:55:42 -0600 Subject: [PATCH 05/22] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5f4ff64..d2f83ec 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ inputs: description: 'SSH address' required: true remote: - description: 'Remote dir path' + description: 'base remote folder' required: true port: description: 'SSH Port' From bc4fb13afa776db33397ccfc507428d796b79526 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 20:11:22 -0600 Subject: [PATCH 06/22] Update entrypoint.sh --- entrypoint.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 3a16525..84eb920 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,4 +4,13 @@ echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE chmod 600 __TEMP_INPUT_KEY_FILE -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=$(cat .git-commit) +if [[ -z "$COMMIT_SHA" ]]; then + echo "No .git-commit file found" + exit 1 +fi + +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}" 2>/dev/null +echo File transfer complete, symlinking & purging old +ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path "./latest" | tail -n +5 | rm -r" From 93b0f4fb862431a9859d4c15b7a8ef579c4250d7 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 20:44:01 -0600 Subject: [PATCH 07/22] Update entrypoint.sh --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 84eb920..38e33da 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,7 @@ echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE chmod 600 __TEMP_INPUT_KEY_FILE -COMMIT_SHA=$(cat .git-commit) +COMMIT_SHA=$(cat ${INPUT_SRC}/.git-commit) if [[ -z "$COMMIT_SHA" ]]; then echo "No .git-commit file found" exit 1 @@ -12,5 +12,6 @@ fi 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}" 2>/dev/null + echo File transfer complete, symlinking & purging old ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path "./latest" | tail -n +5 | rm -r" From 7a6bd2c5c74b5da69575ff3ced5bb5bcdeba9a03 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 20:47:05 -0600 Subject: [PATCH 08/22] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 38e33da..a25fe76 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,7 +6,7 @@ chmod 600 __TEMP_INPUT_KEY_FILE COMMIT_SHA=$(cat ${INPUT_SRC}/.git-commit) if [[ -z "$COMMIT_SHA" ]]; then - echo "No .git-commit file found" + echo "COMMIT_SHA: Could not find file ${INPUT_SRC}/.git-commit" exit 1 fi From 619006f67ed6c18e705d2e8a50349fae96f86c3b Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 20:50:57 -0600 Subject: [PATCH 09/22] Update entrypoint.sh --- entrypoint.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index a25fe76..588ac5f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,5 +13,6 @@ fi 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}" 2>/dev/null -echo File transfer complete, symlinking & purging old -ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path "./latest" | tail -n +5 | rm -r" +echo "File transfer complete, symlinking & purging old" +ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ + -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | rm -r" From 9e5b4bb4688d590d76eb8fe0496aca9cc4f89dfa Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 20:57:02 -0600 Subject: [PATCH 10/22] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 588ac5f..dabf0e5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,6 +13,6 @@ fi 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}" 2>/dev/null -echo "File transfer complete, symlinking & purging old" +echo "File transfer complete, symlinking, purging old" ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | rm -r" From 26910b09abec1be2db9810491f0a496457cb7512 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 20:57:14 -0600 Subject: [PATCH 11/22] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index dabf0e5..73d3502 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -l - +set -e echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE chmod 600 __TEMP_INPUT_KEY_FILE From 4e7b2d2b9fc6a53ff3500fedb7998b6650ef16b1 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 21:03:34 -0600 Subject: [PATCH 12/22] Update entrypoint.sh --- entrypoint.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 73d3502..fc5543f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,6 +13,9 @@ fi 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}" 2>/dev/null -echo "File transfer complete, symlinking, purging old" +echo "File transfer complete." +echo "Symlinking, purging old" +echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" + ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | rm -r" From 7a5f9c9bbdd490841e3f003c6cbc05cea217d76a Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 21:44:04 -0600 Subject: [PATCH 13/22] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index fc5543f..74a57d2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,4 +18,4 @@ echo "Symlinking, purging old" echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ - -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find . -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | rm -r" + -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 > rm_result.txt" From 9a2701b513f7a7cdd0d9a81bfba77d9cb9fe8371 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 22:43:18 -0600 Subject: [PATCH 14/22] Update entrypoint.sh --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 74a57d2..269e4cc 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -17,5 +17,6 @@ echo "File transfer complete." echo "Symlinking, purging old" echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" -ssh -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ +ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ + -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 > rm_result.txt" From d5370c265fa7e46e69fe66d38ed7b65d9c1d83ed Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 22:56:26 -0600 Subject: [PATCH 15/22] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 269e4cc..04b5fc9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,5 +18,5 @@ echo "Symlinking, purging old" echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ - -P "${INPUT_PORT}" "${INPUT_USER}"@"${INPUT_HOST}" \ + "${INPUT_USER}"@"${INPUT_HOST}:${INPUT_PORT}" \ -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 > rm_result.txt" From d949eaab09c7b0eb3bce1a6d51b605a17eae35e2 Mon Sep 17 00:00:00 2001 From: jackz Date: Wed, 11 Dec 2024 23:18:43 -0600 Subject: [PATCH 16/22] Update entrypoint.sh --- entrypoint.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 04b5fc9..81ff326 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,7 @@ #!/bin/sh -l set -e echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE +set -x chmod 600 __TEMP_INPUT_KEY_FILE @@ -9,6 +10,10 @@ if [[ -z "$COMMIT_SHA" ]]; then echo "COMMIT_SHA: Could not find file ${INPUT_SRC}/.git-commit" exit 1 fi +echo "SSH Host: ${INPUT_USER}@${INPUT_HOST}:${INPUT_PORT}" +echo "Local Path: ${INPUT_SRC}" +echo "Remote Path: ${INPUT_REMOTE}" +echo "Commit: ${COMMIT_SHA}" 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}" 2>/dev/null @@ -16,7 +21,6 @@ scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ echo "File transfer complete." echo "Symlinking, purging old" echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" - ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ "${INPUT_USER}"@"${INPUT_HOST}:${INPUT_PORT}" \ -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 > rm_result.txt" From 7123b59216939f8dc41b873e858f8e4f8e5ac416 Mon Sep 17 00:00:00 2001 From: Jackz Date: Thu, 12 Dec 2024 11:05:22 -0600 Subject: [PATCH 17/22] fix port --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 04b5fc9..1671dc0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,5 +18,5 @@ echo "Symlinking, purging old" echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ - "${INPUT_USER}"@"${INPUT_HOST}:${INPUT_PORT}" \ + "${INPUT_USER}"@"${INPUT_HOST}" -p "${INPUT_PORT}" \ -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 > rm_result.txt" From ff8e07e7f2f1ba95a458fba937ebe3541ef91d75 Mon Sep 17 00:00:00 2001 From: jackz Date: Thu, 12 Dec 2024 11:14:19 -0600 Subject: [PATCH 18/22] Update entrypoint.sh --- entrypoint.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 61fe942..e19e180 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,9 +18,7 @@ echo "Commit: ${COMMIT_SHA}" 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}" 2>/dev/null -echo "File transfer complete." -echo "Symlinking, purging old" -echo "Running on ssh: ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest" +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}" \ - -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 > rm_result.txt" + -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | rm -r" From 7462fb0984c6e40ab6a524640ba1e1a93c5b73cd Mon Sep 17 00:00:00 2001 From: Jackz Date: Thu, 12 Dec 2024 19:08:53 -0600 Subject: [PATCH 19/22] remove silence --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index e19e180..b6fd5dd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,7 +16,7 @@ echo "Remote Path: ${INPUT_REMOTE}" echo "Commit: ${COMMIT_SHA}" 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}" 2>/dev/null + -P "${INPUT_PORT}" $INPUT_OPTIONS -r ${INPUT_SRC} "${INPUT_USER}"@"${INPUT_HOST}":"${INPUT_REMOTE}/${COMMIT_SHA}" echo "File transfer complete. Symlinking and purging old entries" ssh -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ From 5160db3212a4b9d5533d732878edb6d54ea7b24d Mon Sep 17 00:00:00 2001 From: Jackz Date: Thu, 12 Dec 2024 19:10:43 -0600 Subject: [PATCH 20/22] fix rm --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index b6fd5dd..98a7cd0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,4 +21,4 @@ scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ 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}" \ - -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | rm -r" + -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | xargs rm -r" From 408ca306085edcbae0b69d3b6a1bc8870e250791 Mon Sep 17 00:00:00 2001 From: Jackz Date: Thu, 12 Dec 2024 22:16:06 -0600 Subject: [PATCH 21/22] fix rm when none --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 98a7cd0..55efbbb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,4 +21,4 @@ scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE \ 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}" \ - -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | xargs rm -r" + -C "ln -s ${INPUT_REMOTE}/${COMMIT_SHA} ${INPUT_REMOTE}/latest && find ${INPUT_REMOTE} -mindepth 1 -maxdepth 1 -type d -not -path './latest' | tail -n +5 | xargs --no-run-if-empty rm -r" From bd4da76485504e913df62468103f04819d381dc4 Mon Sep 17 00:00:00 2001 From: Jackz Date: Thu, 12 Dec 2024 22:26:05 -0600 Subject: [PATCH 22/22] 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}" \