/
fabfile.py
56 lines (42 loc) · 1.15 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
from os import environ
from os.path import dirname, exists
from fabric.api import abort, local, task
THIS_DIR = dirname(__file__)
@task
def develop():
"""
Update environment for local development
"""
venv = environ.get('VIRTUAL_ENV')
if not venv:
abort('You must be in a virtual environment')
local('pip install -r requirements/dev.txt')
local('npm install')
local('captainhook install')
@task
def heroku_package_npm():
"""
Create package.json for heroku
"""
if not exists('package.json'):
local('npm init')
local('npm install')
@task
def heroku_configure():
"""
Configure local environment for a heroku deploy
"""
local(
'heroku config:add '
'BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git'
)
local('heroku config:set '
'ON_HEROKU=true '
'DJANGO_SETTINGS_MODULE=ployst.settings.heroku')
@task
def heroku_deploy():
"""
Push this branch to heroku to deploy it.
"""
this_branch = local("git rev-parse --abbrev-ref HEAD", capture=True)
local("git push --force heroku {0}:master".format(this_branch))