-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·49 lines (39 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
46
47
48
49
#!/usr/local/bin/bash
set -e
set -x
# make sure linting checks pass
make lint
# static
python manage.py collectstatic --noinput
# start postgres server
set +e
DID_WE_START_PG=0
PGDATA=postgres-data/ pg_ctl status | grep 'is running'
# if pg is running, grep will succeed, which means exit code 0
if [ ${PIPESTATUS[1]} -eq 1 ]; then
PGDATA=postgres-data/ pg_ctl start
DID_WE_START_PG=1
fi
set -e
# make sure latest requirements are installed
pip install -U pip
pip install -r requirements.txt
# make sure tests pass
python manage.py test
# stop postgres server
if [ $DID_WE_START_PG -eq 1 ]; then
PGDATA=postgres-data/ pg_ctl stop
fi
# push origin srht
git push -v origin master
# push on github
git push -v github master
# pull on server and reload
ssh [email protected] 'cd /opt/apps/illich \
&& git pull \
&& source venv/bin/activate \
&& pip install -U pip \
&& pip install -r requirements.txt \
&& python manage.py collectstatic --noinput \
&& source .envrc && python manage.py migrate \
&& uwsgi --reload /etc/uwsgi/vassals/illich.ini'