forked from G-Node/gin-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
45 lines (32 loc) · 1.07 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/bash
# run this script as normal user w/o sudo from within the gin-ui root folder.
set -e
CNOC="\033[0m"
CAOK="\033[32;01m"
CERR="\033[31;01m"
CWRN="\033[33;01m"
NODE=/opt/node/bin
HOME=/opt/deploy
sudo -v -p "Certain commands require sudo access. Please enter your password: "
echo -e "Running in ${CAOK}$PWD $CNOC"
REPO=$(basename $PWD)
if [ "$REPO" != "gin-ui" ]; then
echo -e "${CERR}* Not in gin-ui *${CNOC}"
exit 1
fi
echo "Pulling latest changes"
BRANCH=$(sudo -u deploy git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != "master" ]; then
echo -e "${CERR}* Not on branch master${CNOC} [${CWRN}$BRANCH${CNOC}]"
exit 1
fi
sudo -u deploy git pull origin master
echo "Setting up config file"
sudo -u deploy cp /opt/deploy/service_conf/gin-ui/config.json /opt/deploy/gin-ui/src/js/
echo "Installing gin-ui dependencies"
sudo -u deploy -E PATH="$PATH:$NODE" $NODE/npm install
echo "Building gin-ui"
sudo -u deploy -E PATH="$PATH:$NODE" $NODE/npm run build
echo "Reset config file"
sudo -u deploy git checkout src/js/config.json
echo -e "${CAOK}Done${CNOC}."