-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
executable file
·69 lines (56 loc) · 1.89 KB
/
fabfile.py
File metadata and controls
executable file
·69 lines (56 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
"""
This is a Fabric file [see http://www.fabfile.org/ for details].
Fabric is a Python command-line utility for automating tedious
deployment/build tasks, etc.
The purpose of this file is to remove some of the tedium of the
Git workflow for me in this project.
"""
from fabric.api import *
# Project configuration
project_dir = '/Users/tom/Projects/JavaScript/Meteor/Microscope'
git_remote_bitbucket = 'bitbucket'
git_remote_github = 'github'
git_remote_combined = 'all'
def commit_pull_push(msg, branch='master'):
"""
Performs the following Git workflow:
- Commits current state with message
- Performs a `git pull`
- Performs a `git push`
Args:
msg (str) The commit message
branch (Optional[str]) The branch to pull/push to
"""
# Escape any quotes, newlines or other special chars in the commit message
commit_cmd = """git commit -am '{0}'""".format(msg)
pull_cmd_first = "git pull {0} {1}".format(git_remote_github, branch)
pull_cmd_second = "git pull {0} {1}".format(git_remote_bitbucket, branch)
push_cmd = "git push {0} {1}".format(git_remote_combined, branch)
local( "cd {0}".format(project_dir) )
local( commit_cmd )
local( pull_cmd_first )
local( pull_cmd_second )
local( push_cmd )
def deploy(key_path):
local("cd {0}/.deploy".format(project_dir))
local('eval $(ssh-agent)')
local("ssh-add {0}".format(key_path))
local("mup deploy")
def start(key_path):
local("cd {0}/.deploy".format(project_dir))
print("Current working directory:")
local('pwd')
local('eval $(ssh-agent)')
local("ssh-add {0}".format(key_path))
local("mup start")
def stop(key_path):
local("cd {0}/.deploy".format(project_dir))
local('eval $(ssh-agent)')
local("ssh-add {0}".format(key_path))
local("mup stop")
def restart(key_path):
local("cd {0}/.deploy".format(project_dir))
local('eval $(ssh-agent)')
local("ssh-add {0}".format(key_path))
local("mup restart")