Skip to content

Instantly share code, notes, and snippets.

@mathebox
Last active January 9, 2018 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathebox/1cb47a6ee9b3769706dff00ecfede915 to your computer and use it in GitHub Desktop.
Save mathebox/1cb47a6ee9b3769706dff00ecfede915 to your computer and use it in GitHub Desktop.
Script for setting up Github labels
#!/bin/bash
echo -n "GitHub username: "
read USER
echo -n "GitHub password or token: "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
read REPO
REPO_USER=$(echo "$REPO" | cut -f1 -d /)
REPO_NAME=$(echo "$REPO" | cut -f2 -d /)
echo "=> Delete existing labels"
LABELS_RESPONSE=$(curl -s --user "$USER:$PASS" --request GET "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels")
LABELS=($(echo $LABELS_RESPONSE | tr '"' '\n' | grep -e 'https://api.github.com/'))
for label in "${LABELS[@]}"
do
curl -s --user "$USER:$PASS" --request DELETE "${label}"
done
echo "=> Create new labels"
while read -r line || [[ -n "$line" ]]; do
if [ ! -z "${line}" ]; then
label_name=$(echo "$line" | cut -f1 -d ,)
label_color=$(echo "$line" | cut -f2 -d ,)
echo " - Create label '$label_name' with color #$label_color"
data='{"name":"'$label_name'","color":"'$label_color'"}"'
curl -s --user "$USER:$PASS" --request POST --data "$data" "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" > /dev/null
fi
done < "$1"
echo "=> Done"
P0: critical,e11d21
P1: urgent,f7c6c7
P2: required,eb6420
P3: important,fad8c7
P4: nice to have,fef2c0
design,c5def5
feature,c5def5
docs,c5def5
infrastructure,c5def5
refactoring,c5def5
toolkit,c5def5
new component,c5def5
performance,c5def5
bug,c5def5
blocked,cccccc
discussion,c2e0c6
question,c2e0c6
good first issue,777777
PR: ready for merge,006b75
PR: wip,bfdadc
@mathebox
Copy link
Author

run ./gh-labels.sh labels.txt

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