Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubygems/rubygems-chef
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c6446fbf0656
Choose a base ref
...
head repository: rubygems/rubygems-chef
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5b7d020bcbf3
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Dec 28, 2014

  1. more deploy bot work

    dwradcliffe committed Dec 28, 2014
    Copy the full SHA
    cca8c0c View commit details
  2. disable au-m temporarily

    dwradcliffe committed Dec 28, 2014
    Copy the full SHA
    5b7d020 View commit details
4 changes: 2 additions & 2 deletions Berksfile.lock
Original file line number Diff line number Diff line change
@@ -232,7 +232,7 @@ GRAPH
rubygems-backups (0.0.20)
chef-vault (>= 0.0.0)
rubygems-ruby (>= 0.0.0)
rubygems-balancer (0.0.40)
rubygems-balancer (0.0.41)
chef-vault (>= 0.0.0)
logrotate (>= 0.0.0)
nginx (>= 0.0.0)
@@ -275,7 +275,7 @@ GRAPH
dnsimple (>= 0.0.0)
hostname (>= 0.0.0)
rubygems-hosts (0.0.10)
rubygems-hubot (0.0.33)
rubygems-hubot (0.0.41)
chef-vault (>= 0.0.0)
hubot (~> 1.0.2)
nginx (>= 0.0.0)
2 changes: 1 addition & 1 deletion cookbooks/rubygems-balancer/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name 'rubygems-balancer'

version '0.0.40'
version '0.0.41'

depends 'chef-vault'
depends 'logrotate'
48 changes: 24 additions & 24 deletions cookbooks/rubygems-balancer/templates/default/site.conf.erb
Original file line number Diff line number Diff line change
@@ -15,21 +15,21 @@ server {
rewrite ^(.*) https://$host$1 permanent;
<% else %>

if ($geoip_country_code = "CN") {
set $gem_mirror http://au-m.rubygems.org;
}
# if ($geoip_country_code = "CN") {
# set $gem_mirror http://au-m.rubygems.org;
# }

if ($geoip_country_code = "JP") {
set $gem_mirror http://au-m.rubygems.org;
}
# if ($geoip_country_code = "JP") {
# set $gem_mirror http://au-m.rubygems.org;
# }

if ($geoip_country_code = "AU") {
set $gem_mirror http://au-m.rubygems.org;
}
# if ($geoip_country_code = "AU") {
# set $gem_mirror http://au-m.rubygems.org;
# }

if ($geoip_country_code = "NZ") {
set $gem_mirror http://au-m.rubygems.org;
}
# if ($geoip_country_code = "NZ") {
# set $gem_mirror http://au-m.rubygems.org;
# }

if ($continent = "EU") {
set $gem_mirror http://aws-eu-cache01.rubygems.org;
@@ -173,21 +173,21 @@ server {

server_name <%= @server_names.join(" ") %>;

if ($geoip_country_code = "CN") {
set $gem_mirror_ssl https://au-m.rubygems.org;
}
# if ($geoip_country_code = "CN") {
# set $gem_mirror_ssl https://au-m.rubygems.org;
# }

if ($geoip_country_code = "JP") {
set $gem_mirror_ssl https://au-m.rubygems.org;
}
# if ($geoip_country_code = "JP") {
# set $gem_mirror_ssl https://au-m.rubygems.org;
# }

if ($geoip_country_code = "AU") {
set $gem_mirror_ssl https://au-m.rubygems.org;
}
# if ($geoip_country_code = "AU") {
# set $gem_mirror_ssl https://au-m.rubygems.org;
# }

if ($geoip_country_code = "NZ") {
set $gem_mirror_ssl https://au-m.rubygems.org;
}
# if ($geoip_country_code = "NZ") {
# set $gem_mirror_ssl https://au-m.rubygems.org;
# }

if ($continent = "EU") {
set $gem_mirror_ssl https://aws-eu-cache01.rubygems.org;
63 changes: 42 additions & 21 deletions cookbooks/rubygems-hubot/files/default/scripts/deploy.coffee
Original file line number Diff line number Diff line change
@@ -44,31 +44,52 @@ allowedToDeploy = (username) ->
else
false

deploy = (msg, env, branch) ->
unless allowedToDeploy(msg.message.user.name)
console.log "#{msg.message.user.name} tried to deploy!"
msg.send "You are not allowed to deploy! Sorry!"
else
deployKey = Math.round(+new Date()/1000)
url = "https://bot.rubygems.org/deploy/#{deployKey}"
if branch
msg.send "Deploying #{branch} branch to #{env}..."
else
msg.send "Deploying to #{env}..."

async.series [
(callback) ->
exec "git fetch origin", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
(callback) ->
if branch
exec "git checkout #{branch}", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
else
exec "git checkout master", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
(callback) ->
exec "bundle check || bundle install --local --without production", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
(callback) ->
branchCmd = if branch then "BRANCH=#{branch}" else ''
cleanCmd = if 'staging' == env then 'deploy:clean_git_cache' else ''
exec "bundle exec cap #{env} #{cleanCmd} deploy -s user=hubot #{branchCmd}", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
], (err, results) ->
if err
console.log err
msg.send ":x: Deploy to #{env} failed! #{url}"
else
msg.send ":+1: Deployed to #{env}! #{url}"

module.exports = (robot) ->

robot.respond /deploy\s+(production|staging)/i, (msg) ->
unless allowedToDeploy(msg.message.user.name)
console.log "#{msg.message.user.name} tried to deploy!"
msg.send "You are not allowed to deploy! Sorry!"
else
deployKey = Math.round(+new Date()/1000)
env = msg.match[1]
# branch = msg.match[2]
url = "https://bot.rubygems.org/deploy/#{deployKey}"
msg.send "Deploying to #{env}... "
robot.respond /deploy$/i, (msg) ->
msg.send 'Not quite ready for use yet!'

async.series [
(callback) ->
exec "bundle check || bundle install --local --without production", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
(callback) ->
exec "bundle exec cap #{env} deploy -s user=hubot", "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{deployKey}.log", callback
], (err, results) ->
if err
console.log err
msg.send ":x: Deploy to #{env} failed! #{url}"
else
msg.send ":+1: Deployed to #{env}! #{url}"
robot.respond /deploy\s+(production|staging)$/i, (msg) ->
env = msg.match[1]
deploy(msg, env)

robot.respond /deploy\s(\S+)\sto\sstaging$/i, (msg) ->
env = 'staging'
branch = msg.match[1] || 'master'
deploy(msg, env, branch)

robot.router.get '/deploy/:key', (req, res) ->
fs.readFile "#{process.env["HUBOT_DEPLOY_LOG_DIR"]}/#{req.params.key}.log", (err, data) ->
2 changes: 1 addition & 1 deletion cookbooks/rubygems-hubot/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name 'rubygems-hubot'

version '0.0.33'
version '0.0.41'

depends 'chef-vault'
depends 'hubot', '~> 1.0.2'
6 changes: 6 additions & 0 deletions cookbooks/rubygems-hubot/recipes/deploy.rb
Original file line number Diff line number Diff line change
@@ -19,6 +19,12 @@
notifies :run, "execute[bundle_install_deploy]", :immediately
end

execute "setup_git_fetch_for_prs" do
command 'git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"'
cwd "#{node['rubygems-hubot']['deploy_dir']}/staging"
not_if "cd #{node['rubygems-hubot']['deploy_dir']}/staging && git config --get-all remote.origin.fetch | grep -qs 'origin/pr'"
end

execute "bundle_install_deploy" do
command "bundle install --local --deployment"
cwd "#{node['rubygems-hubot']['deploy_dir']}/staging"