Last active
August 29, 2015 14:17
-
-
Save stephenyeargin/d82c1da32f7456f3dc0a to your computer and use it in GitHub Desktop.
Roll Slack Webhooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'octokit' | |
# Config | |
GITHUB_API_TOKEN = '<a token>' | |
GITHUB_ORGANIZATION = '<an organization>' | |
### | |
client = Octokit::Client.new( | |
access_token: GITHUB_API_TOKEN | |
) | |
client.login | |
for repo in client.org_repos(GITHUB_ORGANIZATION) | |
next unless repo['permissions']['admin'] | |
hooks = client.hooks(repo['full_name']) | |
for webhook in hooks | |
next unless /\.slack\.com/.match(webhook['config']['url']) | |
puts repo['full_name'] | |
puts "DELETING: #{webhook['name']} | #{webhook['config']['url']}" | |
puts client.remove_hook(repo['full_name'], webhook['id']) ? 'Deleted!' : 'Failed.' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ruby for/each hurt me, so I made this.