- Make sure you run
bundle install
. - Make sure you have a
GITHUB_TRAVIS_CLEANUP_TOKEN
personal token withadmin:repo_hook
scope. - Run
ruby script.rb
Created
September 16, 2021 23:00
-
-
Save fnando/81062395cbd8e0c8885020bd1d249f82 to your computer and use it in GitHub Desktop.
Script to remove all travis-ci hooks from Github repos
This file contains 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
# frozen_string_literal: true | |
source "https://rubygems.org" | |
gem "octokit" | |
gem "pry-meta" |
This file contains 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
# frozen_string_literal: true | |
require "bundler/setup" | |
require "octokit" | |
client = Octokit::Client.new( | |
access_token: ENV.fetch("GITHUB_TRAVIS_CLEANUP_TOKEN") | |
) | |
client.auto_paginate = true | |
repos = client.repos({}, query: {type: "owner", sort: "asc"}) | |
repos.each do |repo| | |
hooks = client.hooks(repo.id) | |
next if hooks.empty? | |
hooks.each do |hook| | |
next unless hook.config.url.include?("travis-ci") | |
puts "-> removing #{hook.config.url} (#{hook.id}) from #{repo.name}" | |
client.remove_hook(repo.id, hook.id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment