Class: BricksDeploy
- Inherits:
-
Thor
show all
- Includes:
- Configuration, SSHMethods
- Defined in:
- lib/bricks_deploy.rb,
lib/bricks_deploy/ssh_methods.rb,
lib/bricks_deploy/configuration.rb
Defined Under Namespace
Modules: Configuration, SSHMethods
Classes: Generator
Constant Summary
collapse
- LOCAL_DIR =
File.expand_path('..', __FILE__)
Instance Method Summary
collapse
Instance Method Details
#hooks ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/bricks_deploy.rb', line 53
def hooks
hooks_dir = File.join(LOCAL_DIR, 'hooks')
remote_dir = "#{deploy_to}/.git/hooks"
scp_upload "#{hooks_dir}/post-receive.sh" => "#{remote_dir}/post-receive"
run "chmod +x #{remote_dir}/post-receive"
end
|
#init ⇒ Object
17
18
19
20
|
# File 'lib/bricks_deploy.rb', line 17
def init
require 'bricks_deploy/generator'
Generator::start([])
end
|
#log(n = nil) ⇒ Object
94
95
96
97
|
# File 'lib/bricks_deploy.rb', line 94
def log(n = nil)
tail_args = options.tail? ? '-f' : "-n#{n || options.lines}"
run "tail #{tail_args} #{deploy_to}/var/logs/deploy.log"
end
|
#rerun ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/bricks_deploy.rb', line 67
def rerun
run " bash -e -c '\n cd '\#{deploy_to}'\n declare -a revs=( $(git rev-parse HEAD@{1} HEAD) )\n bin/deploy/remote/after_push ${revs[@]} 2>&1 | tee -a var/logs/deploy.log\n '\n BASH\nend\n", :echo => false
|
#restart ⇒ Object
62
63
64
|
# File 'lib/bricks_deploy.rb', line 62
def restart
run "cd #{deploy_to} && bin/deploy/remote/restart 2>&1 | tee -a var/logs/deploy.log"
end
|
#rollback ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/bricks_deploy.rb', line 78
def rollback
run " bash -e -c '\n cd '\#{deploy_to}'\n declare -a revs=( $(git rev-parse HEAD HEAD@{1}) )\n git reset --hard ${revs[1]}\n callback=after_push\n [ -x bin/deploy/remote/rollback ] && callback=rollback\n bin/deploy/remote/$callback ${revs[@]} 2>&1 | tee -a var/logs/deploy.log\n '\n BASH\nend\n", :echo => false
|
#setup ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/bricks_deploy.rb', line 27
def setup
sudo = options.sudo? ? "#{sudo_cmd} " : ''
unless run_test("test -x #{deploy_to}")
run ["#{sudo}mkdir -p #{deploy_to}"] do |cmd|
cmd << "#{sudo}chown $USER #{deploy_to}" if options.sudo?
cmd
end
end
run [] do |cmd|
cmd << "chmod g+ws #{deploy_to}" if options.shared?
cmd << "cd #{deploy_to}"
cmd << "git init #{options.shared? ? '--shared' : ''}"
cmd << "sed -i'' -e 's/master/#{branch}/' .git/HEAD" unless branch == 'master'
cmd << "git config --bool receive.denyNonFastForwards false" if options.shared?
cmd << "git config receive.denyCurrentBranch ignore"
cmd << "mkdir -p etc/"
cmd << "echo #{options.stage} > etc/stage"
cmd << "echo #{options.color} > etc/color"
end
invoke :hooks
end
|
#upload(*files) ⇒ Object
100
101
102
103
104
105
106
107
108
|
# File 'lib/bricks_deploy.rb', line 100
def upload(*files)
files = files.map { |f| Dir[f.strip] }.flatten
abort "Error: Specify at least one file to upload" if files.empty?
scp_upload files.inject({}) { |all, file|
all[file] = File.join(deploy_to, file)
all
}
end
|