Skip to content

Instantly share code, notes, and snippets.

@searls
Last active May 13, 2017 14:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save searls/8449175 to your computer and use it in GitHub Desktop.
Save searls/8449175 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