Compare commits

...

25 commits

Author SHA1 Message Date
bd4da76485 allow auto extarct 2024-12-12 22:26:05 -06:00
408ca30608 fix rm when none 2024-12-12 22:16:06 -06:00
5160db3212 fix rm 2024-12-12 19:10:43 -06:00
7462fb0984 remove silence 2024-12-12 19:08:53 -06:00
ff8e07e7f2 Update entrypoint.sh 2024-12-12 11:14:19 -06:00
80286d41fa Merge branch 'master' of ssh://git.jackz.me:222/jackz/ssh-scp-deploy 2024-12-12 11:05:28 -06:00
7123b59216 fix port 2024-12-12 11:05:22 -06:00
d949eaab09 Update entrypoint.sh 2024-12-11 23:18:43 -06:00
d5370c265f Update entrypoint.sh 2024-12-11 22:56:26 -06:00
9a2701b513 Update entrypoint.sh 2024-12-11 22:43:18 -06:00
7a5f9c9bbd Update entrypoint.sh 2024-12-11 21:44:04 -06:00
4e7b2d2b9f Update entrypoint.sh 2024-12-11 21:03:34 -06:00
26910b09ab Update entrypoint.sh 2024-12-11 20:57:14 -06:00
9e5b4bb468 Update entrypoint.sh 2024-12-11 20:57:02 -06:00
619006f67e Update entrypoint.sh 2024-12-11 20:50:57 -06:00
7a6bd2c5c7 Update entrypoint.sh 2024-12-11 20:47:05 -06:00
93b0f4fb86 Update entrypoint.sh 2024-12-11 20:44:01 -06:00
bc4fb13afa Update entrypoint.sh 2024-12-11 20:11:22 -06:00
c4ecacfccb Update action.yml 2024-12-11 18:55:42 -06:00
Fabricio Nogueira
48b9ca0b1a
Merge pull request #2 from Hermanverschooten/add_options
Add parameter for extra options
2021-07-21 10:39:01 -03:00
Herman verschooten
08d0e7cde1 Add parameter for extra options 2021-05-06 19:03:27 +02:00
Fabricio Nogueira
c72c8bbce7
Merge pull request #1 from nikolakadic/master
README typo fix :)
2020-11-10 11:38:58 -03:00
Nikola Kadić
ad4ef26acf
Typo fix :) 2020-11-05 15:36:21 +01:00
Fabricio Nogueira
1d25b00c26 fix(docker): Fix install scp command in container 2020-06-05 18:48:26 -03:00
Fabricio Nogueira
614178c124 refactor(docker): Reduce docker image final size 2020-06-05 18:29:58 -03:00
6 changed files with 52 additions and 13 deletions

5
.dockerignore Normal file
View file

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

3
.gitignore vendored
View file

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

View file

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

View file

@ -4,12 +4,13 @@ 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
- `user`: SSH User name
- `key`: Private key
- `options` : Extra options for scp
### To publish
@ -59,4 +60,4 @@ jobs:
port: ${{ secrets.SSH_PORT }}
user: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
```
```

View file

@ -1,29 +1,35 @@
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'
required: true
remote:
description: 'Remote dir path'
description: 'base remote folder'
required: true
port:
description: 'SSH Port'
required: false
default: 22
default: "22"
user:
description: 'SSH User name'
required: true
key:
description: 'Private key'
required: true
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'
branding:
icon: 'upload-cloud'
color: 'blue'
color: 'blue'

View file

@ -1,7 +1,31 @@
#!/bin/sh -l
set -e
echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE
set -x
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}"
COMMIT_SHA=$(cat ${INPUT_SRC}/.git-commit)
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"