Skip to content
Snippets Groups Projects
Commit 3541220f authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add a static build stage to the deployment process

parent e9cde2b7
No related branches found
No related tags found
No related merge requests found
import os
from datetime import datetime
from fabric.api import roles, runs_once, run, local, env, prompt, get
from fabric.api import lcd, roles, runs_once, run, local, env, prompt, get
env.roledefs = {
......@@ -50,8 +50,8 @@ def pull_production_media():
@roles('staging')
def deploy_staging():
# Remove this line when you're happy that this task is correct
raise RuntimeError("Please check the fabfile before using it")
build_static()
deploy_static()
run('git pull')
run('pip install -r requirements.txt')
......@@ -150,3 +150,21 @@ def _post_deploy():
# update search index
run('django-admin update_index')
@runs_once
def build_static():
# Build a specific branch
build_branch = 'master'
current_branch = local('git rev-parse --abbrev-ref HEAD')
if current_branch != build_branch:
raise RuntimeError("Please switch to '{}' before deploying".format(build_branch))
local('git pull')
with lcd('/vagrant/opentech/static_src/'):
local('yarn build:prod')
@runs_once
def deploy_static():
# Copy the compiled static files to the server
local("rsync -avz /vagrant/opentech/static_compiled %s:'../app/opentech/'" % (env['host_string']))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment