atech_cloud 1.0.8 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/atech_cloud/deploy.rb +57 -1
- metadata +3 -3
data/lib/atech_cloud/deploy.rb
CHANGED
@@ -8,6 +8,9 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
8
8
|
set :user, `whoami`.chomp
|
9
9
|
set :ssh_options, {:forward_agent => true, :port => 22}
|
10
10
|
|
11
|
+
## Set the `current_revision`
|
12
|
+
set(:current_revision) { capture("cd #{deploy_to} && git log --pretty=%H -n 1", :except => { :no_release => true }).chomp }
|
13
|
+
|
11
14
|
## Return the deployment path
|
12
15
|
def deploy_to
|
13
16
|
fetch(:deploy_to, nil) || "/opt/apps/#{fetch(:application)}"
|
@@ -24,6 +27,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
24
27
|
task :default do
|
25
28
|
update_code
|
26
29
|
restart
|
30
|
+
codebase.log_deployment
|
27
31
|
end
|
28
32
|
|
29
33
|
desc 'Deploy and migrate the database before restart'
|
@@ -63,7 +67,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
63
67
|
|
64
68
|
desc 'Upload the database configuration file'
|
65
69
|
task :upload_db_config, :roles => [:app, :storage] do
|
66
|
-
put "production:\n adapter: mysql2\n encoding: utf8\n reconnect:
|
70
|
+
put "production:\n adapter: mysql2\n encoding: utf8\n reconnect: true\n database: #{fetch(:application, 'databasename')}\n pool: 5\n username: #{fetch(:application, 'dbusernmae')}\n password: #{ENV['DBPASS'] || 'xxxx'}\n host: #{fetch(:database_host, 'db-a-vip.cloud.atechmedia.net')}\n", File.join(deploy_to, 'config', 'database.yml')
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
@@ -150,4 +154,56 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
157
|
+
## ==================================================================
|
158
|
+
## Codebase Tasks
|
159
|
+
## ==================================================================
|
160
|
+
|
161
|
+
namespace :codebase do
|
162
|
+
|
163
|
+
desc 'Displays a list of all commits to be deployed in the next deployment'
|
164
|
+
task :pending do
|
165
|
+
current_local = `git log #{branch} --pretty=%H -n 1`.chomp
|
166
|
+
exec("git log #{current_revision}..#{current_local}")
|
167
|
+
end
|
168
|
+
|
169
|
+
desc 'Log the current deployment in Codebase'
|
170
|
+
task :log_deployment do
|
171
|
+
|
172
|
+
## Check the repository URL
|
173
|
+
if fetch(:repository) =~ /git\@codebasehq.com\:(.+)\/(.+)\/(.+)\.git\z/
|
174
|
+
account, project, repo = $1, $2, $3
|
175
|
+
else
|
176
|
+
puts " \e[31mRepository URL does not match a valid Codebase repository\e[0m"
|
177
|
+
next
|
178
|
+
end
|
179
|
+
|
180
|
+
## Check to that the token is valid etc...
|
181
|
+
if `cb test #{account}.codebasehq.com > /dev/null 2> /dev/null` && !$?.success?
|
182
|
+
puts " \e[31mYou do not have a token for #{account}.codebasehq.com configured.\e[0m"
|
183
|
+
next
|
184
|
+
end
|
185
|
+
|
186
|
+
## Get the revisions
|
187
|
+
releases = capture("cd #{deploy_to} && git log rollback --pretty=%H -n 1 && git log deploy --pretty=%H -n 1").chomp
|
188
|
+
rollback, current = releases.split(/\n/)
|
189
|
+
if rollback == current
|
190
|
+
puts " \e[31mThe current and rollback release are the same, nothing to log.\e[0m"
|
191
|
+
next
|
192
|
+
end
|
193
|
+
|
194
|
+
cmd = ["cb deploy #{rollback} #{current}"]
|
195
|
+
cmd << "-s #{roles.values.collect{|r| r.servers}.flatten.collect{|s| s.host}.uniq.join(',') rescue ''}"
|
196
|
+
cmd << "-b #{branch}"
|
197
|
+
cmd << "-r #{project}:#{repo}"
|
198
|
+
cmd << "-h #{account}.codebasehq.com"
|
199
|
+
cmd << "--protocol https"
|
200
|
+
|
201
|
+
for environment in environments
|
202
|
+
command_to_run = "#{cmd.join(' ')} -e #{environment}"
|
203
|
+
puts " * running: #{command_to_run}"
|
204
|
+
system(command_to_run + "; true")
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
153
209
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atech_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-06 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: adam@atechmedia.com
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 1.8.
|
43
|
+
rubygems_version: 1.8.10
|
44
44
|
signing_key:
|
45
45
|
specification_version: 3
|
46
46
|
summary: The RubyGem for the aTech Cloud
|