2020-01-05 19:11:59 +08:00
|
|
|
#!/bin/sh
|
2019-02-09 21:17:45 +08:00
|
|
|
|
2023-06-08 23:35:29 +08:00
|
|
|
if [ -z "$(echo "$INPUT_REMOTE_PATH" | awk '{$1=$1};1')" ]; then
|
2023-06-08 23:23:41 +08:00
|
|
|
echo "The remote_path can not be empty. see: github.com/Burnett01/rsync-deployments/issues/44"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-05 19:06:14 +08:00
|
|
|
# Start the SSH agent and load key.
|
|
|
|
source agent-start "$GITHUB_ACTION"
|
2021-08-03 03:57:01 +08:00
|
|
|
echo "$INPUT_REMOTE_KEY" | SSH_PASS="$INPUT_REMOTE_KEY_PASS" agent-add
|
2019-02-09 21:17:45 +08:00
|
|
|
|
2020-06-23 03:40:12 +08:00
|
|
|
# Add strict errors.
|
2020-01-05 19:19:21 +08:00
|
|
|
set -eu
|
2020-06-23 03:40:12 +08:00
|
|
|
|
|
|
|
# Variables.
|
2024-03-06 19:16:35 +08:00
|
|
|
LEGACY_RSA_HOSTKEYS="-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
|
|
|
|
LEGACY_RSA_HOSTKEYS=$([ "$INPUT_LEGACY_ALLOW_RSA_HOSTKEYS" = "true" ] && echo "$LEGACY_RSA_HOSTKEYS" || echo "")
|
|
|
|
|
2020-06-23 03:40:12 +08:00
|
|
|
SWITCHES="$INPUT_SWITCHES"
|
2024-03-06 19:16:35 +08:00
|
|
|
RSH="ssh -o StrictHostKeyChecking=no $LEGACY_RSA_HOSTKEYS -p $INPUT_REMOTE_PORT $INPUT_RSH"
|
2020-06-23 03:40:12 +08:00
|
|
|
LOCAL_PATH="$GITHUB_WORKSPACE/$INPUT_PATH"
|
|
|
|
DSN="$INPUT_REMOTE_USER@$INPUT_REMOTE_HOST"
|
|
|
|
|
|
|
|
# Deploy.
|
|
|
|
sh -c "rsync $SWITCHES -e '$RSH' $LOCAL_PATH $DSN:$INPUT_REMOTE_PATH"
|