ruby gistfile1.rb octokit/octokit.rb
Last active
August 2, 2018 11:54
-
-
Save fmasuhr/a3863994252175bf2fcc to your computer and use it in GitHub Desktop.
Add own labels to GitHub repository
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' | |
LABELS = [{ name: 'almost ready to merge', color: 'bfe5bf' }, | |
{ name: 'dependency missing', color: 'fbca04' }, | |
{ name: 'do not merge', color: 'e11d21' }, | |
{ name: 'ready to merge', color: '0e8a16' }, | |
{ name: 'refactoring expected', color: 'fbca04' }, | |
{ name: 'work in progress', color: 'fbca04' }] | |
repository = ARGV[0] | |
raise 'Specify repository fullname as first parameter e.g. \'octokit/octokit.rb\'' unless repository | |
github = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN']) | |
labels = github.labels(repository) | |
# Remove all existing labels | |
labels.each { |label| github.delete_label!(repository, label.name) } | |
# Add new labels | |
LABELS.each { |label| github.add_label(repository, label[:name], label[:color]) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment