This repository was archived by the owner on Dec 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathfabfile.py
More file actions
48 lines (37 loc) · 1.42 KB
/
fabfile.py
File metadata and controls
48 lines (37 loc) · 1.42 KB
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
"""
The easy button for deployment
Add your SSH key :
$ ssh-add ~/.ssh/oabutton.pem
Identity added: /Users/victorng/.ssh/oabutton.pem (/Users/victorng/.ssh/oabutton.pem)
# Run prepare_deploy:
$ fab prepare_deploy
# Run deploy:
$ fab -H ubuntu@staging.openaccessbutton.org deploy
"""
from fabric.api import local, settings, cd, run, env
from os.path import join
def prepare_deploy():
local("pip install -r requirements.txt")
local("make test")
local("git add -p && git commit")
local("git push")
def deploy():
code_dir = '/home/ubuntu/dev/OAButton/'
BIN_DIR = "/home/ubuntu/.virtualenvs/oabutton/bin"
PIP_BIN = join(BIN_DIR, 'pip')
PYTHON_BIN = join(BIN_DIR, 'python')
with settings(warn_only=True):
with cd(code_dir):
run("git pull")
run("git checkout %s" % env.release_tag)
run("%s install -r requirements.txt" % PIP_BIN)
version_path = join(code_dir,
'oabutton',
'static',
'public',
'version.txt')
run("git rev-parse --short HEAD > %s" % version_path)
# We don't need syncdb anymore as south is enabled now
#run("%s manage.py syncdb" % PYTHON_BIN)
run("%s manage.py migrate bookmarklet" % PYTHON_BIN)
run("sudo supervisorctl restart oabutton")