forked from SamKirkland/FTP-Deploy-Action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
28 lines (21 loc) · 848 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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