Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Maxopoly/e651f82cd88b5835b35752c8e92b2147 to your computer and use it in GitHub Desktop.
Save Maxopoly/e651f82cd88b5835b35752c8e92b2147 to your computer and use it in GitHub Desktop.
A terminal script to setup GitHub issue labels for a project.
#!/bin/bash
echo -n "GitHub User: "
read USER
#echo -n "GitHub Password: "
#Hardcoded token to circumvent 2 factor auth and for easy repeated usage for different repos
PASS="REPLACE WITH GITHUB TOKEN"
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 /)
# Delete default labels
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/bug"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/bug"
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/duplicate"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/duplicate"
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/enhancement"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/enhancement"
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/help%20wanted"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/help%20wanted"
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/invalid"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/invalid"
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/question"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/question"
#echo "DELETE https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/wontfix"
#curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/wontfix"
# Create labels
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"bug","color":"e11d21"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"regression","color":"eb6420"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"enhancement","color":"207de5"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"feature","color":"0052cc"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"task","color":"0052cc"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"discussion","color":"fbca04"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"question","color":"cc317c"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"help wanted","color":"009800"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"pull request welcome","color":"009800"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"more information needed","color":"009800"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"duplicate","color":"e6e6e6"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"invalid","color":"e6e6e6"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"wontfix","color":"e6e6e6"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"P0 - ASAP","color":"ff0000"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"P1 - Critical","color":"e11d21"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"P2 - Needed","color":"eb6420"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"P3 - Nice to have","color":"006b75"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"P4 - Someday maybe","color":"5319e7"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
Setup GitHub issue labels script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment