Compare commits

..

No commits in common. "master" and "v1.1.1" have entirely different histories.

6 changed files with 13 additions and 52 deletions

View file

@ -1,5 +0,0 @@
*
*./*
*/*
*.*
!*.sh

3
.gitignore vendored
View file

@ -1,3 +1,2 @@
.history .history
.vscode .vscode
*.log

View file

@ -1,9 +1,7 @@
FROM alpine:3.10 FROM alpine:3.10
RUN apk upgrade --update \ COPY LICENSE README.md /
&& apk add --update openssh \
&& rm -rf /tmp/* /usr/share/man /var/cache/apk/*
COPY . / COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

View file

@ -4,13 +4,12 @@ Action to send dist files to a remote server with scp command
## Required params ## Required params
- `src`: Source dir to deploy - `src`: Sorce dir to deploy
- `host`: SSH address - `host`: SSH address
- `remote`: Remote dir path - `remote`: Remote dir path
- `port`: SSH Port - `port`: SSH Port
- `user`: SSH User name - `user`: SSH User name
- `key`: Private key - `key`: Private key
- `options` : Extra options for scp
### To publish ### To publish
@ -60,4 +59,4 @@ jobs:
port: ${{ secrets.SSH_PORT }} port: ${{ secrets.SSH_PORT }}
user: ${{ secrets.SSH_USER }} user: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }} key: ${{ secrets.SSH_KEY }}
``` ```

View file

@ -1,35 +1,29 @@
name: 'SCP Deploy Smart' name: 'SCP deploy action'
description: 'Action to send dist files to a remote server with scp command' description: 'Action to send dist files to a remote server with scp command'
author: 'Fabricio Nogueira & Jackz' author: 'Fabricio Nogueira'
inputs: inputs:
src: src:
description: 'Source dir to deploy' description: 'Sorce dir to deploy'
required: true required: true
host: host:
description: 'SSH address' description: 'SSH address'
required: true required: true
remote: remote:
description: 'base remote folder' description: 'Remote dir path'
required: true required: true
port: port:
description: 'SSH Port' description: 'SSH Port'
required: false required: false
default: "22" default: 22
user: user:
description: 'SSH User name' description: 'SSH User name'
required: true required: true
key: key:
description: 'Private key' description: 'Private key'
required: true required: true
options:
description: 'Extra options for scp'
required: false
extract:
description: 'Is src a tar file to be extracted?'
required: false
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile' image: 'Dockerfile'
branding: branding:
icon: 'upload-cloud' icon: 'upload-cloud'
color: 'blue' color: 'blue'

View file

@ -1,31 +1,7 @@
#!/bin/sh -l #!/bin/sh -l
set -e
echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE
set -x
chmod 600 __TEMP_INPUT_KEY_FILE chmod 600 __TEMP_INPUT_KEY_FILE
COMMIT_SHA=$(cat ${INPUT_SRC}/.git-commit) scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "${INPUT_PORT}" -r ${INPUT_SRC} "${INPUT_USER}"@"${INPUT_HOST}":"${INPUT_REMOTE}"
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}"
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}" \
-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"