-
Notifications
You must be signed in to change notification settings - Fork 42
/
deploy
executable file
·39 lines (33 loc) · 1.17 KB
/
deploy
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
#!/bin/bash
set -o nounset
set -o errexit
set -o xtrace
CIRCLE_PROJECT_USERNAME=${CIRCLE_PROJECT_USERNAME:-""}
CIRCLE_PR_NUMBER=${CIRCLE_PR_NUMBER:-""}
if [ "$CIRCLE_PROJECT_USERNAME" != 'ucscXena' ] || [ ! -z $CIRCLE_PR_NUMBER ]; then
exit;
fi
USER=ubuntu
BUILD_DJANGO=build-django
RSYNC_OPTS=(-a --delete -e "ssh -o StrictHostKeyChecking=no")
npm run build:prod -- --bail
# deploy
rsync "${RSYNC_OPTS[@]}" --rsync-path='sudo rsync' build/ ${USER}@${HOST}:/var/www/html
# copy to clean load directory, so we can rsync --delete
rm -rf ${BUILD_DJANGO}
mkdir ${BUILD_DJANGO}
cp -a manage.py server bookmarks ties ${BUILD_DJANGO}
rsync "${RSYNC_OPTS[@]}" ${BUILD_DJANGO}/ ${USER}@${HOST}:/var/www/backend/django
requirements=$(cat requirements.txt)
requirements=$(echo ${requirements}) # drop carriage returns
ssh -l${USER} ${HOST} <<-ENDSSH
#set -o nounset # 'activate' accesses unbound vars
set -o errexit
set -o xtrace
cp ~/settings/site_settings.py /var/www/backend/django/server/site_settings.py
. /var/www/backend/virtualenv/bin/activate
pip install ${requirements}
cd /var/www/backend/django
python ./manage.py migrate
sudo apache2ctl restart
ENDSSH