Skip to content

Instantly share code, notes, and snippets.

@fmasuhr
Last active August 2, 2018 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmasuhr/a3863994252175bf2fcc to your computer and use it in GitHub Desktop.
Save fmasuhr/a3863994252175bf2fcc to your computer and use it in GitHub Desktop.
Add own labels to GitHub repository
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]) }

Usage

ruby gistfile1.rb octokit/octokit.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment