Last active
January 11, 2022 15:27
-
-
Save tylerpearson/fda868b17ca0d4e4c7e8 to your computer and use it in GitHub Desktop.
Super simple script to copy Github tag labels from one repository to another. Uses the Octokit gem.
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
require 'octokit' | |
# https://help.github.com/articles/creating-an-access-token-for-command-line-use/ | |
client = Octokit::Client.new(:access_token => "getmefromgithub") | |
COPY_FROM_REPO = "repo/old" | |
COPY_TO_REPO = "repo/new" | |
current_labels = client.labels(COPY_FROM_REPO) | |
current_labels.each do |label| | |
begin | |
client.add_label(COPY_TO_REPO, label.name, label.color) | |
puts "Added #{label.name} - ##{label.color}" | |
rescue Exception => e | |
puts "#{label.name} already exists" if e.class == Octokit::UnprocessableEntity | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used this one instead: https://gist.github.com/douglascayers/9fbc6f2ad899f12030c31f428f912b5c