Skip to content

Commit

Permalink
Add 'group' parameter, and updte docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbjones committed Nov 9, 2021
1 parent 8fe0412 commit fb64a14
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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/"
Expand Down
16 changes: 10 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 3 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fb64a14

Please sign in to comment.