Last active
February 4, 2016 23:09
-
-
Save anthonycarminati/4724b03e5b96aee8e0fe to your computer and use it in GitHub Desktop.
Revisions
-
anthonycarminati revised this gist
Feb 4, 2016 . 1 changed file with 32 additions and 36 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,54 +5,50 @@ declare -A LABELS # Platform LABELS["platform:ruby"]="BFD4F2" LABELS["platform:sql"]="BFD4F2" LABELS["platform:python"]="BFD4F2" LABELS["platform:groove"]="BFD4F2" LABELS["platform:c++"]="BFD4F2" LABELS["platform:node.js"]="BFD4F2" LABELS["platform:html"]="BFD4F2" LABELS["platform:bash/os"]="BFD4F2" # Important LABELS["important:bug"]="EE3F46" LABELS["important:security"]="EE3F46" LABELS["important:production"]="EE3F46" # Admin LABELS["admin:chore"]="FEF2C0" LABELS["admin:legal"]="FEF2C0" # Experience LABELS["experience:graphics"]="FFC274" LABELS["experience:ui/ux"]="FFC274" # Environment LABELS["env:developement"]="FAD8C7" LABELS["env:testing"]="FAD8C7" LABELS["env:production"]="FAD8C7" # Feedback LABELS["feedback:discussion"]="CC317C" LABELS["feedback:question"]="CC317C" # Improvements LABELS["improve:enhancement"]="5EBEFF" LABELS["improve:optimizaiton"]="5EBEFF" # Pending LABELS["pending:in progress"]="FBCA04" LABELS["pending:watchlist"]="FBCA04" # Inactive LABELS["inactive:invalid"]="D2DAE1" LABELS["inactive:wontfix"]="D2DAE1" LABELS["inactive:duplicate"]="D2DAE1" LABELS["inactive:on hold"]="D2DAE1" ### # Get a token from Github -
anthonycarminati created this gist
Feb 4, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ ### # Label definitions ### declare -A LABELS # Platform LABELS["ruby"]="BFD4F2" LABELS["sql"]="BFD4F2" LABELS["python"]="BFD4F2" LABELS["groove"]="BFD4F2" LABELS["c++"]="BFD4F2" LABELS["node.js"]="BFD4F2" LABELS["html"]="BFD4F2" LABELS["bash/os"]="BFD4F2" # Problems LABELS["bug"]="EE3F46" LABELS["security"]="EE3F46" LABELS["production"]="EE3F46" # Mindless LABELS["chore"]="FEF2C0" LABELS["legal"]="FEF2C0" # Experience LABELS["graphics"]="FFC274" LABELS["ui/ux"]="FFC274" # Environment LABELS["developement"]="FAD8C7" LABELS["testing"]="FAD8C7" LABELS["production"]="FAD8C7" # Feedback LABELS["discussion"]="CC317C" LABELS["rfc"]="CC317C" LABELS["question"]="CC317C" # Improvements LABELS["enhancement"]="5EBEFF" LABELS["optimizaiton"]="5EBEFF" # Additions LABELS["feature"]="91CA55" # Pending LABELS["in progress"]="FBCA04" LABELS["watchlist"]="FBCA04" # Inactive LABELS["invalid"]="D2DAE1" LABELS["wontfix"]="D2DAE1" LABELS["duplicate"]="D2DAE1" LABELS["on hold"]="D2DAE1" ### # Get a token from Github ### TOKEN=$(cat .token) read -p "Who owns the repo you want labels on?: " owner read -p "What repo do you want labels on?: " repo for K in "${!LABELS[@]}"; do CURL_OUTPUT=$(curl -s -H "Authorization: token $TOKEN" -X POST "https://api.github.com/repos/$owner/$repo/labels" -d "{\"name\":\"$K\", \"color\":\"${LABELS[$K]}\"}") HAS_ERROR=$(echo "$CURL_OUTPUT" | jq -r '.errors') if [ ! -z "$HAS_ERROR" ] && [ "$HAS_ERROR" != null ]; then ERROR=$(echo "$CURL_OUTPUT" | jq -r '.errors[0].code') if [ "$ERROR" == "already_exists" ]; then # We update echo "'$K' already exists. Updating..." CURL_OUTPUT=$(curl -s -H "Authorization: token $TOKEN" -X PATCH "https://api.github.com/repos/$owner/$repo/labels/${K/ /%20}" -d "{\"name\":\"$K\", \"color\":\"${LABELS[$K]}\"}") else echo "Unknown error: $ERROR" echo "Output from curl: " echo "$CURL_OUTPUT" echo "Exiting..." exit 1; fi else echo "Created '$K'." fi done exit 0