burnett01-rsync-deployments/entrypoint.sh

19 lines
466 B
Bash
Raw Normal View History

2019-12-05 01:29:34 +08:00
#!/bin/bash
2019-02-09 21:17:45 +08:00
set -eu
# Set deploy key
SSH_PATH="$HOME/.ssh"
2019-12-05 01:29:34 +08:00
# Create .ssh dir if it doesn't exist
2019-12-05 01:29:34 +08:00
[ -d "$SSH_PATH" ] || mkdir "$SSH_PATH"
# Place deploy_key into .ssh dir
2019-12-05 01:29:34 +08:00
echo "$INPUT_REMOTE_KEY" > "$SSH_PATH/key"
# Set r+w to user only
2019-12-05 01:29:34 +08:00
chmod 600 "$SSH_PATH/key"
2019-02-09 21:17:45 +08:00
# Do deployment
2019-12-05 01:29:34 +08:00
sh -c "rsync $INPUT_SWITCHES -e 'ssh -i $SSH_PATH/key -o StrictHostKeyChecking=no $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_REMOTE_USER@$INPUT_REMOTE_HOST:$INPUT_REMOTE_PATH"