From fb64a1416fb9f0a4605834949cf412b60df90386 Mon Sep 17 00:00:00 2001 From: Matt Jones Date: Mon, 8 Nov 2021 22:28:49 -0900 Subject: [PATCH] Add 'group' parameter, and updte docs. --- README.md | 6 ++++-- action.yml | 16 ++++++++++------ entrypoint.sh | 7 +++---- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4a492f5..bfe2f7a 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ Deploy files to a TARGET host using rsync by configuring an appropriate ssh KEY. ## Required Parameters - `host`: Remote Hostname -- `username`: Remote Host Username - `port`: Remote Host SSH Port -- `key`: Remote Host SSH Private key +- `username`: Remote Host Username +- `group`: Remote Host Group for files +- `key`: Remote Host SSH Private key for user - `source`: Source files location (rsync naming conventions) - `target`: Remote Host deployment location (rsync naming conventions) @@ -39,6 +40,7 @@ jobs: uses: dataone/rsync-deploy@latest with: host: ${{ secrets.HOST }} + group: ${{ secrets.GROUP }} username: ${{ secrets.USERNAME }} key: ${{ secrets.KEY }} source: "/tmp/sourcedir/" diff --git a/action.yml b/action.yml index 5635b86..538c53d 100644 --- a/action.yml +++ b/action.yml @@ -5,21 +5,25 @@ inputs: host: description: 'ssh remote host' required: true - username: - description: 'ssh remote user' - required: true port: description: 'ssh remote port' default: 22 + username: + description: 'ssh remote user' + required: true + group: + description: 'ssh remote group' + required: false + default: 'web-dev' key: description: 'content of ssh private key. ex raw content of ~/.ssh/id_rsa' - required: false + required: true source: description: 'source to copy from' - required: false + required: true target: description: 'destination to deploy to on server' - required: false + required: true runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index 43a4599..62689f8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,9 @@ # as secrets: # INPUT_KEY: ssh private key of the user to be logged in on the deployment host # INPUT_USERNAME: username of the user to be logged in on the deployment host +# INPUT_GROUP: group to use for files copied to the deployment host (default: web-dev) # INPUT_HOST: the target host for deployment +# INPUT_PORT: the target port for deployment # INPUT_SOURCE: the directory to copy files from # INPUT_TARGET: the directory for files to be copied to on the deployment host # INPUT_PUBLISH: the directory where final files are published after they have been deployed to the host; not currently used @@ -16,17 +18,14 @@ echo "+++++++++++++++++++STARTING TRANSFER+++++++++++++++++++" if [[ "$INPUT_KEY" ]]; then - #echo -n "Working dir: " - #echo `pwd` echo -e "${INPUT_KEY}" > tmp_id chmod 600 tmp_id - #echo `ifconfig` mkdir -p /root/.ssh && \ chmod 0700 /root/.ssh && \ ssh-keyscan ${INPUT_HOST} > /root/.ssh/known_hosts ssh -p ${INPUT_PORT} -i tmp_id ${INPUT_USERNAME}@${INPUT_HOST} "mkdir -p $INPUT_TARGET" rsync -rav -e "ssh -i tmp_id -p ${INPUT_PORT}" ${INPUT_SOURCE} $INPUT_USERNAME@$INPUT_HOST:$INPUT_TARGET - ssh -p ${INPUT_PORT} -i tmp_id ${INPUT_USERNAME}@${INPUT_HOST} "chgrp -R web-dev ${INPUT_TARGET}; chmod -R g+rwx ${INPUT_TARGET}" + ssh -p ${INPUT_PORT} -i tmp_id ${INPUT_USERNAME}@${INPUT_HOST} "chgrp -R ${INPUT_GROUP} ${INPUT_TARGET}; chmod -R g+rwx ${INPUT_TARGET}" #ssh -p ${INPUT_PORT} $INPUT_USERNAME@$INPUT_HOST "if [ -d ${INPUT_PUBLISH}_old ]; then rm -r ${INPUT_PUBLISH}_old; fi; if [ -d ${INPUT_PUBLISH} ]; then mv ${INPUT_PUBLISH} ${INPUT_PUBLISH}_old; fi; mv ${INPUT_TARGET} ${INPUT_PUBLISH}; chgrp -R web-dev ${INPUT_PUBLISH}; chmod -R g+rwx ${INPUT_PUBLISH}" echo "Transfer process complete using rsync over SSH with keys" else