Created
December 4, 2012 02:53
-
-
Save datacodesolutions/4200113 to your computer and use it in GitHub Desktop.
Fab Deploy
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
| # 1. Install fabric: sudo pip install fabric | |
| # 2. Use this file with the name of fabfile.py and place it in project root. | |
| # 3. Execute deploy: fab staging deploy | |
| from __future__ import with_statement | |
| from fabric.api import * | |
| from fabric.contrib.console import confirm | |
| env.key_filename = ["/path/to/ssh/key"] | |
| path = '' | |
| def staging(): | |
| global env, path | |
| env.hosts = ['deploydomain.com'] | |
| env.user = 'remoteuser' | |
| path = '/remote/path/to/repo' | |
| local("git push bitbucket staging") | |
| def master(): | |
| global env, path | |
| env.hosts = ['deploydomain.com'] | |
| env.user = 'remoteuser' | |
| path = '/remote/path/to/repo' | |
| local("git push bitbucket master") | |
| def deploy(): | |
| global env, path | |
| commit_hash = local("git rev-parse HEAD", capture=True) | |
| with cd(path): | |
| run("git fetch bitbucket") | |
| run("git reset --hard " + str(commit_hash)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment