Skip to content

Instantly share code, notes, and snippets.

@arthurfurlan
Created February 14, 2014 11:35
Show Gist options
  • Select an option

  • Save arthurfurlan/8999655 to your computer and use it in GitHub Desktop.

Select an option

Save arthurfurlan/8999655 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# written by Configr Inc. <hello@configr.com>
from fabric.api import *
import os
## available environments
def production():
env.hosts = ['root@oscar.confi.gr']
env.branch = 'master';
env.app_root = '/srv/example.com/www'
env.git_repo = 'https://github.com/paypal/rest-api-sdk-python.git'
env.disabled = False
## available commands
def deploy():
## validate config
if not hasattr(env, 'app_root'):
print 'ERROR: unknown environment.'
os.sys.exit(1)
## environment disabled
if getattr(env, 'disabled', False):
print 'ERROR: disabled environment.'
os.sys.exit(1)
## clone repo
command = 'cd "%s"; test -d %s.git || git clone %s _tmp; mv _tmp/* _tmp/.git* .; rmdir _tmp'
run(command % (os.path.dirname(env.app_root), env.app_root, env.git_repo))
## update code
command = 'cd "%s" && git pull && git checkout -B %s origin/%s && git pull'
run(command % (env.app_root, env.branch, env.branch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment