Skip to content

Instantly share code, notes, and snippets.

@tylerpearson
Last active January 11, 2022 15:27
Show Gist options
  • Save tylerpearson/fda868b17ca0d4e4c7e8 to your computer and use it in GitHub Desktop.
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.
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
@tylerpearson
Copy link
Author

@Margen67 this script is 7 years old, that doesn’t surprise me

@Margen67
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment