-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bash_profile.sh
69 lines (59 loc) · 2.54 KB
/
.bash_profile.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
#------------------------------------------- DEPLOY ---------------------------------------------------------------
deployMenu() {
noInstallDependencies=$1
deployPath=$(jq -r '.["prod-deploy-path"]' ./package.json)
if [[ $deployPath != null && $deployPath != "" ]]; then
# deployIt "$deployPath"
while true; do
read -p "Do you wish to deploy to $deployPath" yn
case $yn in
[Yy]* ) deployIt "$deployPath" "$noInstallDependencies" && break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "No Deploy Path"
return 1
fi
}
deployIt() {
#set -x
deployServerUser=$(jq -r '.["prod-deploy-server-user"]' ./package.json)
deployServerIp=$(jq -r '.["prod-deploy-server-ip"]' ./package.json)
deployServerPort=$(jq -r '.["prod-deploy-server-port"]' ./package.json)
if [[ $deployServerUser == null || $deployServerUser == "" || $deployServerIp == null || $deployServerIp == "" || $deployServerPort == null || $deployServerPort == "" ]]; then
echo "No Deploy Server"
return 1
fi
deployPath=$1
noInstallDependencies=$2
deployShellScript=$(jq '.["prod-deploy-shell-script"]' ./package.json)
echo "Deploying to $deployPath ($deployServerUser@$deployServerIp:$deployServerPort)"
gulp build
eval rsync -auz -r -e \"ssh -p $deployServerPort\" --delete --recursive dist/ $deployServerUser@$deployServerIp:$deployPath #--progress to show progress
if [[ $deployPath == null || $deployPath == "" ]]; then
echo "No Deploy Path"
return 1
fi
if [[ $deployShellScript != null && $deployShellScript != "" ]]; then
pwdPath=$(dirname $deployPath)
echo "Copying package.json & bower.json to $pwdPath"
eval rsync -auz -r -e \"ssh -p $deployServerPort\" --progress {bower.json,package.json} $deployServerUser@$deployServerIp:$pwdPath
if [[ $noInstallDependencies == 'true' ]]; then
echo ">>>> NO INSTALL"
ssh -p $deployServerPort -t $deployServerUser@$deployServerIp "sudo bash \"$deployShellScript\" 'true'"
else
ssh -p $deployServerPort -t $deployServerUser@$deployServerIp sudo bash \"$deployShellScript\"
fi
fi
localGit=$(jq -r '.["local-git"]' ./package.json)
if [[ $localGit != "true" ]]; then
echo "pushing to git $localGit"
git push origin master
fi
copyProcessFiles=$(jq -r '.["copy-process-files"]' ./package.json)
if [[ $copyProcessFiles == "true" ]]; then
eval rsync -auz -r -e \"ssh -p $deployServerPort\" --progress {processes.json,deploy.sh} $deployServerUser@$deployServerIp:$pwdPath
fi
}