-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfabfile.py
86 lines (72 loc) · 2.05 KB
/
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from fabric.api import *
"""
Base configuration
"""
#name of the deployed site if different from the name of the project
env.site_name = 'transit'
env.project_name = 'transit'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.repository_url = "[email protected]:hacktyler/hacktyler-transit.git"
env.phonegap_repo = "[email protected]:onyxfish/13467_hacktylertransit.git"
"""
Environments
"""
def production():
"""
Work on production environment
"""
env.settings = 'production'
env.s3_bucket = 'media.hacktyler.com'
env.app_s3_bucket = 'transit.hacktyler.com'
def staging():
"""
Work on staging environment
"""
env.settings = 'staging'
env.s3_bucket = 'media-beta.hacktyler.com'
env.app_s3_bucket = 'transit-beta.hacktyler.com'
"""
Branches
"""
def stable():
"""
Work on stable branch.
"""
env.branch = 'stable'
def master():
"""
Work on development branch.
"""
env.branch = 'master'
def branch(branch_name):
"""
Work on any specified branch.
"""
env.branch = branch_name
"""
Commands - deployment
"""
def deploy_phonegap():
require('settings', provided_by=[production, staging])
local('DEPLOYMENT_TARGET=%(settings)s PHONEGAP_REPO=%(phonegap_repo)s ./update_phonegap.sh' % env)
def gzip_assets():
"""
GZips every file in the assets directory and places the new file
in the gzip directory with the same filename.
"""
local('python gzip_assets.py')
def deploy_s3():
"""
Deploy the latest project site media to S3.
"""
require('settings', provided_by=[production, staging])
gzip_assets()
env.gzip_path = 'gzip/'
local('s3cmd -P --add-header=Content-encoding:gzip --guess-mime-type --rexclude-from=s3exclude sync %(gzip_path)s s3://%(app_s3_bucket)s/' % env)
local('s3cmd put -P app/config-%(settings)s.js s3://%(app_s3_bucket)s/js/config.js' % env)
def local_app():
"""
Runs a local web server to test the web app
"""
local('cd app/web && python -m SimpleHTTPServer 8000')