Skip to content

Instantly share code, notes, and snippets.

@rentzsch
Last active July 1, 2021 22:10
Show Gist options
  • Star 52 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save rentzsch/4540430 to your computer and use it in GitHub Desktop.
Save rentzsch/4540430 to your computer and use it in GitHub Desktop.
Shell script to set up a GitHub Project's Issues' Labels as described in <http://rentzsch.tumblr.com/post/252878320/my-lighthouse-ticket-settings-with-colors>. WARNING: script assumes a newish project that hasn't really used labels yet. It deletes all default labels, which means DATA LOSS if you've used them for anything.
USER=rentzsch
PASS=mypassword
REPO=mogenerator
# Delete default labels
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/bug"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/duplicate"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/enhancement"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/invalid"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/question"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/wontfix"
# Create labels
curl --user "$USER:$PASS" --include --request POST --data '{"name":"accepted","color":"66aa00"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"reproduced","color":"006600"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"cantreproduce","color":"996361"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"fixcommitted","color":"003B84"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"bluesky","color":"66ccff"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"duplicate","color":"aaaaaa"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"declined","color":"83000C"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"new","color":"ff1177"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"fixreleased","color":"3f3f3f"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"resolved","color":"3f3f3f"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"wishlist","color":"66Aa00"}' "https://api.github.com/repos/$USER/$REPO/labels"
@hubertursua
Copy link

Thanks for this gist!

You can check out my fork. Modified the script a bit so that it reads the variables. And I separated the GitHub user from the repo's primary user (I needed this for repos owned by organizations).

@stkent
Copy link

stkent commented Jan 16, 2016

Hello! What is the license applied to this Gist? Looking to give attribution. Thanks!

@davegreenwp
Copy link

Huge thanks for this, made implementing this in our scaffolding bash script much easier! 👍

@santoshyatnam
Copy link

@hyubs I get error while running this
git-labels.sh: 5: read: Illegal option -s

@AlexSkrypnyk
Copy link

Guys, check out my for of this one with some sensible defaults https://github.com/integratedexperts/github-labels

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