diff --git a/fabfile.py b/fabfile.py index a7f0d249cba7f6098d48269dcb886bb8815e0782..3a46e0b5c044cf777a2937b419770a11b9a3746f 100644 --- a/fabfile.py +++ b/fabfile.py @@ -49,7 +49,7 @@ def pull_production_media(): @roles('staging') def deploy_staging(): - _build_static() + _build_static(build_branch='staging') _deploy_static() run('git pull') @@ -84,6 +84,22 @@ def pull_staging_media(): local('rsync -avz %s:\'%s\' /vagrant/media/' % (env['host_string'], '$CFG_MEDIA_DIR')) +@roles('pre-production') +def deploy_pre_production(): + _build_static() + _deploy_static() + + run('git pull') + run('pip install -r requirements.txt') + _run_migrate() + run('django-admin collectstatic --noinput') + + # 'restart' should be an alias to a script that restarts the web server + run('restart') + + _post_deploy() + + @runs_once def _pull_data(env_name, remote_db_name, local_db_name, remote_dump_path, local_dump_path): timestamp = datetime.now().strftime('%Y%m%d-%I%M%S') @@ -153,9 +169,8 @@ def _post_deploy(): @runs_once -def _build_static(): +def _build_static(build_branch='master'): # Build a specific branch - build_branch = 'master' current_branch = local('git rev-parse --abbrev-ref HEAD', capture=True) if current_branch != build_branch: raise RuntimeError("Please switch to '{}' before deploying".format(build_branch))