Guest User

Untitled

a guest
Jun 25th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. require 'github_v3_api'
  2. g = g=GitHubV3API.new(ENV['GITHUB_OAUTH2_TOKEN'])
  3.  
  4. cfa = g.orgs.list.first
  5.  
  6. names = cfa.repos.map(&:name)
  7.  
  8. names.each do |name|
  9. hooks = g.get("/repos/codeforamerica/#{name}/hooks")
  10. scream_hook = hooks.find {|h| h["name"] == "web" && h["config"]["url"] =~ /6178/}
  11. if scream_hook
  12. unless scream_hook["config"]["url"] =~ /97.65.119.3/
  13. puts "updating #{name}"
  14. g.patch("/repos/codeforamerica/#{name}/hooks/#{scream_hook['id']}",{
  15. "name"=>"web",
  16. "config"=>scream_hook["config"].merge({"url"=>"97.65.119.3:6178/receive_commit"}),
  17. })
  18. end
  19. else
  20. puts "creating #{name}"
  21. g.post("/repos/codeforamerica/#{name}/hooks",{
  22. "name"=>"web",
  23. "active"=>true,
  24. "config"=>{
  25. "url"=>"97.65.119.3:6178/receive_commit"
  26. }
  27. })
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment