-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·45 lines (35 loc) · 1.1 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
#!/bin/sh
set -ex
if [ -z $1 ] ; then
echo "USER:IP parameter required!" && exit 1;
fi
if [ -z $2 ] ; then
echo "SERVER_HOME_PATH parameter required!" && exit 1;
fi
USER_AT_IP=$1
SERVER_HOME_PATH=$2
BRANCH=${3:-"develop"}
if [ "$BRANCH" = "master" ]; then
ENVIRONMENT="production"
FOLDER_NAME="perps-keepers"
else
FOLDER_NAME="perps-keepers-staging"
ENVIRONMENT="staging"
fi
join_path() {
echo "${1:+$1/}$2" | sed 's#//#/#g'
}
FULL_SERVER_PATH=$(join_path $SERVER_HOME_PATH $FOLDER_NAME)
echo "Creating folder if not exists"
ssh "$USER_AT_IP" mkdir -p "$FULL_SERVER_PATH"
echo "Uploading files"
rsync --exclude 'node_modules' --exclude 'build' --exclude 'coverage' --exclude 'cache' -e "ssh" -Pav "$PWD/" "$USER_AT_IP":"$FULL_SERVER_PATH"
echo "Installing deps, transpiling typescript"
ssh "$USER_AT_IP" "cd $FOLDER_NAME;npm i;npm run build"
if [ "$ENVIRONMENT" = "production" ]; then
echo "Starting mainnet keeper"
ssh "$USER_AT_IP" "cd $FOLDER_NAME;npm run start:mainnet"
else
echo "Starting goerli keeper"
ssh "$USER_AT_IP" "cd $FOLDER_NAME;npm run start:goerli"
fi