Last active
January 10, 2016 05:21
-
-
Save ericlbarnes/6629050 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# easy installation: | |
# brew install python | |
# sudo easy_install pip # PIP is recommended for installation | |
# sudo -s # Creates a new sudo shell | |
# export ARCHFLAGS="-arch i386 -arch x86_64" # Need to set some GCC flags | |
# exit | |
# sudo pip install fabric # Get the install on | |
# sudo pip install python-simple-hipchat | |
import os, getpass, random, hipchat | |
from fabric.api import * | |
from fabric.contrib.files import exists | |
# ------------------------------------------------------------------------ | |
# Setup Environments | |
# ------------------------------------------------------------------------ | |
env.roledefs = { | |
'production': ['[email protected]'], | |
'development': ['[email protected]'] | |
} | |
# ------------------------------------------------------------------------ | |
# Run a git pull on the production site | |
# ------------------------------------------------------------------------ | |
@roles('production') | |
def prod(): | |
print("Executing on %(host)s as %(user)s" % env) | |
run('git pull github master') | |
notify("production") | |
# ------------------------------------------------------------------------ | |
# Run a git pull on the development site | |
# ------------------------------------------------------------------------ | |
@roles('development') | |
def dev(branch = 'develop'): | |
print("Executing on %(host)s as %(user)s" % env) | |
run('php artisan migrate:reset --env=development') | |
run('git fetch github') | |
run("git checkout github/%s --detach" % (branch)) | |
run("php artisan migrate --seed --env=development") | |
run('./vendor/bin/phpunit') | |
notify("development") | |
# ------------------------------------------------------------------------ | |
# Notify hipchat of a deploy | |
# ------------------------------------------------------------------------ | |
def notify(env): | |
hipster = hipchat.HipChat(token="tokenhere") | |
msg = getpass.getuser().capitalize() + ' deployed to ' + env + ' environment.' | |
if env == 'development': | |
color = 'purple' | |
else: | |
color = 'red' | |
print hipster.method('rooms/message', method='POST', parameters={'room_id': 12345, 'from': 'FabFile', 'message': msg, 'color': 'red'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment