-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdeploy.sh
executable file
·78 lines (63 loc) · 1.99 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
72
73
74
75
76
77
78
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m' # No Color
INPLACE=false
PW=""
while getopts "h?ip:" opt; do
case $opt in
i)
INPLACE=true
;;
p)
PW=$OPTARG
;;
h|\?)
echo "Usage: "
echo " -h Display this help message."
echo " -i In-place deployment. Script will skip SSHing, clone and repo sync, and instead will deploy functions from current directory."
echo " -p password Pass the git secret password for secret file decryption. You will be prompted for the password if this option is not specified."
exit 0
;;
esac
done
function readPassword {
read -sp "Enter git secret password for file decryption: " PW
echo
}
function validatePassword {
size=${#PW}
if [ $size -lt 1 ]; then
echo -e "${RED}Password length was 0.${NC}"
exit 3
fi
}
if [ ! $PW ]; then
readPassword
fi
validatePassword
if [ $INPLACE == true ]; then
git secret reveal -d .gnupg -p "$PW" -f
faas build -f functions.yml
faas deploy -f functions.yml
echo "Deployment finished!"
else
deployTarget=$FUNC_DEPLOY_TARGET
if [ ! $deployTarget ]; then
echo -e "${RED}Could not find SSH deployment target variable \$FUNC_DEPLOY_TARGET${NC}"
exit 3
fi
echo "Remember to push this repository to source control before running deploy command."
echo "Using SSH deployment target from environment variable \$FUNC_DEPLOY_TARGET."
# COMMAND=$(cat <<-EOF
# if [ ! -d azure-functions ]; then git clone "https://github.com/nozzlegear/azure-functions.git"; fi
# && cd azure-functions
# && git pull
# && git secret reveal -f
# && faas build -f functions.yml
# && faas deploy -f functions.yml
# EOF
# )
COMMAND="if [ ! -d azure-functions ]; then git clone 'https://github.com/nozzlegear/azure-functions.git'; fi && cd azure-functions && git pull && bash deploy.sh -ip '$PW' && rm */env.yml && cp cron/* /etc/cron.d"
ssh "$FUNC_DEPLOY_TARGET" "$COMMAND"
fi
#3: