-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.rb
executable file
·35 lines (28 loc) · 986 Bytes
/
deploy.rb
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
#!/usr/bin/env ruby
require 'fog'
stage = ENV['DEPLOYMENT_ENV'] || 'staging'
secrets = JSON.parse(File.read('secrets.json'))
if secrets['rackspace_api_key']
compute = Fog::Compute.new({
:provider => "Rackspace",
:rackspace_username => secrets['rackspace_username'],
:rackspace_api_key => secrets['rackspace_api_key'],
:rackspace_region => secrets['rackspace_region']
})
end
servers = []
secrets['deployment_tags'].each do |tag|
servers += compute.servers.select {|s| s.name.include?(stage) && s.name.include?(tag)}.map(&:ipv4_address)
end
IO.popen("grunt build") do |output|
output.each do |line|
puts line
end
end
servers.each do |server|
IO.popen("rsync -avuz dist/ #{secrets['deployment_user']}@#{server}:#{secrets['deployment_path']}") do |output|
output.each do |line|
puts line
end
end
end