Skip to content

Instantly share code, notes, and snippets.

@liuderchi
Last active June 23, 2022 12:40
Show Gist options
  • Save liuderchi/8d1c8e0a74fd690523288acedd163682 to your computer and use it in GitHub Desktop.
Save liuderchi/8d1c8e0a74fd690523288acedd163682 to your computer and use it in GitHub Desktop.
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