Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
To Create Labels for your Repo
#!/bin/bash
set -e
# NOTE to create labels for your repo
# to support types from commit message guide (feat, fix, docs, style, refactor, test, chore)
# by hitting GitHub API v3
#
# https://developer.github.com/v3/issues/labels/#create-a-label
# https://gist.github.com/caspyin/2288960
# 1. Create your github PERSONAL ACCESS TOKEN at https://github.com/settings/tokens
# 2. Enter these fields
GH_TOKEN_PATH= # path to your PERSONAL ACCESS TOKEN
USERNAME= # your github login id
REPO= # your repository name
# 3. Hit GitHub API
# NOTE would create label with ": " prefix
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": feat","color":"1d76db"}'
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": fix","color":"e99695"}'
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": docs","color":"c5def5"}'
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": style","color":"bfdadc"}'
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": refactor","color":"c2e0c6"}'
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": test","color":"fef2c0"}'
curl -f -X POST https://api.github.com/repos/$USERNAME/$REPO/labels -H "Authorization: token $(cat $GH_TOKEN_PATH)" -d '{"name":": chore","color":"d4c5f9"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.