Skip to content

Instantly share code, notes, and snippets.

@ptierno
Forked from searls/octohooks.rb
Last active August 29, 2015 14:25
Show Gist options
  • Save ptierno/e368bb4323f76daa7886 to your computer and use it in GitHub Desktop.
Save ptierno/e368bb4323f76daa7886 to your computer and use it in GitHub Desktop.
Use Octokit to add a particular webhook to all of your repos (handy for things like chat integration)
# This is just a scratchpad after I hacked what I needed in an irb session
require 'octokit'
Octokit.configure do |c|
c.login = 'searls'
c.password = 'c0d3b4ssssss!'
end
client = Octokit::Client.new
repos = client.repos #Note, for an org's repos, see `client.orgs.first.rels[:repos].get.data`
repos.each do |repo|
if repo.permissions.admin
client.create_hook(repo.full_name, 'web',
{
:url => 'https://some/hook/url',
:content_type => 'json'
},
{ :active => true }
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment