Skip to content

Instantly share code, notes, and snippets.

@arthurfurlan
Created January 24, 2014 00:30
Show Gist options
  • Select an option

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

Select an option

Save arthurfurlan/8589776 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# written by Arthur Furlan <afurlan@confi.gr>
from fabric.api import *
import os
## available environments
def production():
env.hosts = ['root@rupia.ibpt.org.br']
env.branch = 'master'
env.app_root = '/srv/deolhonoimposto.ibpt.org.br/www/ibpt-deolhonoimposto'
env.git_repo = 'git@github.com:ibptech/ibpt-deolhonoimposto.git'
env.disabled = False
def development():
env.hosts = ['root@rupia.ibpt.org.br']
env.branch = 'develop'
env.app_root = '/srv/dev.deolhonoimposto.ibpt.org.br/www/ibpt-deolhonoimposto'
env.git_repo = 'git@github.com:ibptech/ibpt-deolhonoimposto.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'
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