burnett01-rsync-deployments/entrypoint.sh

18 lines
451 B
Bash
Raw Normal View History

2019-02-09 21:17:45 +08:00
#!/bin/sh
set -eu
# Set deploy key
SSH_PATH="$HOME/.ssh"
# Create .ssh dir if it doesn't exist
2019-11-13 05:55:41 +08:00
if [ ! -d "$SSH_PATH" ]; then
mkdir "$SSH_PATH"
fi
# Place deploy_key into .ssh dir
2019-02-09 21:17:45 +08:00
echo "$DEPLOY_KEY" > "$SSH_PATH/deploy_key"
# Set r+w to user only
2019-02-09 21:17:45 +08:00
chmod 600 "$SSH_PATH/deploy_key"
# Do deployment
sh -c "rsync $INPUT_SWITCHES -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_UPLOAD_PATH"