-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
58 lines (37 loc) · 1004 Bytes
/
fabfile.py
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
50
51
52
53
54
55
56
57
58
from fabric.api import local, settings, abort
from fabric.contrib.console import confirm
# prepare for deployment
def test():
with settings(warn_only=True):
result = local(
"python test_tasks.py -v && python test_users.py -v", capture=True
)
if result.failed and not confirm("Tests failed. Continue?"):
abort("Aborted at user request.")
def commit():
message = raw_input("Enter a git commit message: ")
local("git add . && git commit -am '{}'".format(message))
def push():
local("git push origin master")
def prepare():
test()
commit()
push()
# deploy to heroku
def pull():
local("git pull origin master")
def heroku():
local("git push heroku master")
def heroku_test():
local(
"heroku run python test_tasks.py -v && heroku run python test_users.py -v"
)
def deploy():
pull()
test()
commit()
heroku()
heroku_test()
# rollback
def rollback():
local("heroku rollback")