diff --git a/buildout.d/production.cfg b/buildout.d/production.cfg index 711c850..1f4ea2a 100644 --- a/buildout.d/production.cfg +++ b/buildout.d/production.cfg @@ -1,6 +1,6 @@ [buildout] extends = base.cfg eggs += - iw.rotatezlogs + eestec.portal [production] -# TODO \ No newline at end of file +# TODO diff --git a/buildout.d/staging.cfg b/buildout.d/staging.cfg new file mode 100644 index 0000000..2a067ef --- /dev/null +++ b/buildout.d/staging.cfg @@ -0,0 +1,2 @@ +[buildout] +extends = production.cfg diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..77aaa69 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,51 @@ +from fabric.api import env, run, local +from fabric.context_managers import settings, cd, lcd +from fabric.decorators import task + +env.hosts = ['staging.eestec.net'] +env.user = 'staging' +env.repository = "https://github.com/eestec/eestec.portal.git" +env.branch = "master" +env.staging_folder = "/home/staging/env" + + +@task +def staging_bootstrap(): + with settings(warn_only=True): + run('%(staging_folder)s/bin/supervisorctl shutdown' % env) + run('rm -rf %(staging_folder)s' % env) + run('git clone %(repository)s %(staging_folder)s' % env) + # TODO: install crontab + staging_deploy() + + +@task +def has_new_commits(): + """Check for fresh deploy branch commits""" + with lcd(env.staging_folder): + local('git fetch origin') + output = local('git log %(branch)s...origin/%(branch)s' % env, + capture=True) + if output.strip(): + local('git pull origin') + print "new commits!" + return True + else: + print "no new commits." + return False + + +@task +def staging_update(): + if not has_new_commits(): + return + staging_deploy() + + +@task +def staging_deploy(): + with cd(env.staging_folder): + # TODO: copy production data + run('bin/buildout -c buildout.d/staging.cfg') + run('bin/supervisord') + # TODO: run upgrade profile diff --git a/setup.py b/setup.py index 83907c0..92d4b76 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,11 @@ def read(*rnames): 'setuptools-flakes', 'zest.releaser', 'jarn.mkrelease', + 'Fabric', ], + 'production': [ + 'Fabric', + ] }, entry_points=""" [z3c.autoinclude.plugin]