-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeploy.sh
71 lines (60 loc) · 1.39 KB
/
deploy.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Abort if a command fails!
set -e
TEMP_DIR=/tmp/
if [ ! -n "$HOST" ];then
echo "missing option \"HOST\", aborting"
exit 1
fi
if [ ! -n "$USER" ];then
echo "missing option \"HOST\", aborting"
exit 1
fi
if [ ! -n "$PASSWORD" ];then
echo "missing option \"HOST\", aborting"
exit 1
fi
if [ ! -n "$DIRECTORY" ];then
echo "missing option \"DIRECTORY\", aborting"
exit 1
fi
if [ ! -n "$IGNORE" ];then
IGNORE=''
fi
# Create temporary director
WORKING_DIR="$TEMP_DIR/workspace"
# TODO: fail if exists..
mkdir -p $WORKING_DIR
export COMPOSER_HOME="$WORKING_DIR"
# Clone the repo & checkout branch
echo "Creating archive..."
git archive master --format=tar --output=$TEMP_DIR/export.tar
tar -xf $TEMP_DIR/export.tar -C $WORKING_DIR
# Change directory into the working dir
cd "$WORKING_DIR"
# install the dependencies
echo "Install dependencies..."
composer install --no-dev --optimize-autoloader
# Prepare ignore parameters
IFS=';' read -a igor <<< "$IGNORE"
params=''
for element in "${igor[@]}"
do
params=$(echo "$params --exclude $element")
done
# TODO: allow SFTP
# TODO: allow verify cert
echo "Uploading..."
lftp -e "
open $HOST
set ssl:verify-certificate no
set ftp:ssl-allow off
set cmd:fail-exit true
user $USER $PASSWORD
cd $DIRECTORY
mirror --reverse $params --delete --ignore-time --verbose --parallel . .
bye
"
# Complete!
echo "Done!"
exit 0