from __future__ import with_statement from fabric.api import * from fabric.contrib.console import confirm env.hosts = ['home2.esculap.pl'] def deploy(): code_dir = '/data/web/cms.esculap.com' code_dir_tmp = '/tmp/cms.esculap.com' project = "cms.esculap.com" remote_project = '/data/web/deploy-cms.esculap.com' with settings(warn_only=True): if run("test -d %s" % code_dir_tmp).failed: run("git clone ssh://git@stash.esculap.pl:7999/cms_com/cms.esculap.com.git %s" % code_dir_tmp) else: with cd(code_dir_tmp): run("git pull") with cd(code_dir_tmp): revision = run("rev=$(git show --pretty=%H | sed -n '1p'); echo $rev") releasePath = "%s/release/%s_%s" % (remote_project, project, revision) releasePath.strip() if run("test -d %s" % releasePath).failed: run("mkdir %s" % releasePath) with cd(releasePath): run("git clone ssh://git@stash.esculap.pl:7999/cms_com/cms.esculap.com.git .") run("git pull") run("php composer.phar update --prefer-dist") run("/bin/cp -fr %s/app-data/config/ %s/" % (remote_project, releasePath)) run("chown apache:apache %s -R" % releasePath) with cd("/data/web"): run("ln -sfn %s %s" % (releasePath, project))