Skip to content

Instantly share code, notes, and snippets.

@jschroed91
Last active January 9, 2020 15:55
Show Gist options
  • Save jschroed91/1a18cd468626ed250b25e9f2cbb51f02 to your computer and use it in GitHub Desktop.
Save jschroed91/1a18cd468626ed250b25e9f2cbb51f02 to your computer and use it in GitHub Desktop.
Caxy Github Labels

This is a labels.json file to be used with the github-labels tool (node). The github-labels tool creates labels on a github repository by using a json file defining the label names and colors.

This is Caxy's default labels that faciliate the Caxy code review process.

Usage

Install github-labels globally if you don't have it

$ yarn global add github-labels

Download the labels.json from this gist to your machine if you don't have it:

$ wget -O ~/labels.json https://gist.githubusercontent.com/jschroed91/1a18cd468626ed250b25e9f2cbb51f02/raw/labels.json

Use the shell script to run this

  1. Grab a copy of the shell script and save it locally
wget -O ~/github_labels.sh https://gist.githubusercontent.com/jschroed91/1a18cd468626ed250b25e9f2cbb51f02/raw/github_labels.sh
  1. Generate personal access token (be sure to copy it): https://github.com/settings/tokens/new?scopes=repo&description=github-labels

  2. Edit the ~/github_labels.sh script and paste your personal access token in there to set the TOKEN variable. Save the file.

# ...

TOKEN=your-token-here

# ...
  1. Run the command to clear out a repo's labels and add the caxy standard labels
$ sh ~/github_labels.sh caxy/repository-name

Alternate Option: Run the labels command manually

  1. Generate personal access token: https://github.com/settings/tokens/new?scopes=repo&description=github-labels
  2. Copy the access token
  3. Run the labels command using the -t option like below (replacing PERSONAL_ACCESS_TOKEN with your token):
$ labels -c labels.json -t PERSONAL_ACCESS_TOKEN caxy/name-of-repository

You'll need to use the token anytime you want to run that command - so you can either save a copy of the token somewhere to re-use later, or you can always regenerate a personal access token on github.

Options

By default, the command adds the labels to the already existing labels. Sometimes you want to wipe out existing labels and add only these (for example when setting up a new repo).

Overwrite the existing labels by using the force option (-f, --force):

$ labels -f -c labels.json -t PERSONAL_ACCESS_TOKEN caxy/name-of-repository
#!/bin/bash
# Usage: sh github_labels.sh caxy/repository-name
# Generate a github token from URL and set TOKEN to your new token.
# https://github.com/settings/tokens/new?scopes=repo&description=github-labels
#
TOKEN=your-github-token
labels -c ~/labels.json -t $TOKEN -f $1
[
{
"name": "Status: Approved",
"color": "0e8a16"
},
{
"name": "Status: Blocked by Other PR",
"color": "e99695"
},
{
"name": "Status: In Review",
"color": "c5def5"
},
{
"name": "Status: Needs Rebase",
"color": "fbca04"
},
{
"name": "Status: Needs Review",
"color": "1d76db"
},
{
"name": "Status: Needs Updates",
"color": "fbca04"
},
{
"name": "Status: On Hold",
"color": "e99695"
},
{
"name": "Status: Question(s)",
"color": "cc317c"
},
{
"name": "Status: Updated - Needs Review",
"color": "5319e7"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment