Skip to content

Instantly share code, notes, and snippets.

@evan
Last active December 19, 2015 10:08
Show Gist options
  • Save evan/5937649 to your computer and use it in GitHub Desktop.
Save evan/5937649 to your computer and use it in GitHub Desktop.
Enable all types of github notifications for all your github hooks.
#!/usr/bin/env ruby
require 'json'
require 'pp'
user = ENV['USER']
pass = ENV['PASS']
notifications = %w(commit_comment create delete download follow fork fork_apply gist gollum
issue_comment issues member public pull_request push team_add watch
pull_request_review_comment status)
notifications_json = {"events" => notifications}.to_json
# get all repos
repos = JSON.parse(`curl --silent -u '#{user}:#{pass}' https://api.github.com/user/repos`)
repos.each do |repo|
# get hooks
JSON.parse(`curl --silent -u '#{ user}:#{pass}' https://api.github.com/repos/#{user}/#{repo["name"]}/hooks`).each do |hook|
# enable notifications for hook
pp JSON.parse(`curl --silent -u '#{user}:#{pass}' -XPOST https://api.github.com/repos/#{user}/#{repo["name"]}/hooks/#{hook["id"]} -d #{notifications_json.inspect}`)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment