Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment