mirror of
https://github.com/SamKirkland/FTP-Deploy-Action.git
synced 2025-08-14 14:05:05 +00:00
29 lines
848 B
Bash
29 lines
848 B
Bash
#!/bin/sh
|
|
|
|
# "to avoid continuing when errors or undefined variables are present"
|
|
set -eu
|
|
|
|
echo "Starting FTP Deploy"
|
|
|
|
WDEFAULT_LOCAL_DIR=${LOCAL_DIR:-"."}
|
|
WDEFAULT_REMOTE_DIR=${REMOTE_DIR:-"."}
|
|
WDEFAULT_ARGS=${ARGS:-""}
|
|
WDEFAULT_METHOD=${METHOD:-"ftp"}
|
|
|
|
if [ $WDEFAULT_METHOD = "sftp" ]; then
|
|
WDEFAULT_PORT=${PORT:-"22"}
|
|
echo "Establishing SFTP connection..."
|
|
sshpass -p $FTP_PASSWORD sftp -o StrictHostKeyChecking=no -P $WDEFAULT_PORT $FTP_USERNAME@$FTP_SERVER
|
|
echo "Connection established"
|
|
else
|
|
WDEFAULT_PORT=${PORT:-"21"}
|
|
fi;
|
|
|
|
echo "Using $WDEFAULT_METHOD to connect to port $WDEFAULT_PORT"
|
|
|
|
echo "Uploading files..."
|
|
lftp $WDEFAULT_METHOD://$FTP_SERVER:$WDEFAULT_PORT -u $FTP_USERNAME,$FTP_PASSWORD -e "set ftp:ssl-allow no; mirror $WDEFAULT_ARGS -R $WDEFAULT_LOCAL_DIR $WDEFAULT_REMOTE_DIR; quit"
|
|
|
|
echo "FTP Deploy Complete"
|
|
exit 0
|