Skip to content

Instantly share code, notes, and snippets.

@YenTheFirst
Created November 9, 2011 21:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save YenTheFirst/1353188 to your computer and use it in GitHub Desktop.
Save YenTheFirst/1353188 to your computer and use it in GitHub Desktop.
require 'github_v3_api'
g = g=GitHubV3API.new(ENV['GITHUB_OAUTH2_TOKEN'])
cfa = g.orgs.list.first
names = cfa.repos.map(&:name)
names.each do |name|
hooks = g.get("/repos/codeforamerica/#{name}/hooks")
scream_hook = hooks.find {|h| h["name"] == "web" && h["config"]["url"] =~ /6178/}
if scream_hook
unless scream_hook["config"]["url"] =~ /97.65.119.3/
puts "updating #{name}"
g.patch("/repos/codeforamerica/#{name}/hooks/#{scream_hook['id']}",{
"name"=>"web",
"config"=>scream_hook["config"].merge({"url"=>"97.65.119.3:6178/receive_commit"}),
})
end
else
puts "creating #{name}"
g.post("/repos/codeforamerica/#{name}/hooks",{
"name"=>"web",
"active"=>true,
"config"=>{
"url"=>"97.65.119.3:6178/receive_commit"
}
})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment