Forked from hubertursua/setup github issues labels.sh
Last active
January 26, 2025 14:45
-
-
Save adamreisnz/8d3a67b426ee6e834473 to your computer and use it in GitHub Desktop.
A terminal script to setup GitHub issue labels for a project.
This file contains 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 characters
#!/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 /) | |
# 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" | |
# Bug, 3rd party bug, error | |
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
curl --user "$USER:$PASS" --include --request POST --data '{"name":"bug","color":"b60205"}' "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":"3rd party bug","color":"b60205"}' "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":"error","color":"b60205"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
# Regression, refactoring, security | |
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
curl --user "$USER:$PASS" --include --request POST --data '{"name":"regression","color":"d93f0b"}' "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":"refactoring","color":"d93f0b"}' "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":"security","color":"d93f0b"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
# Feature, enhancement, task, test, question | |
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":"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":"task","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":"test","color":"cc317c"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
# Discussion, question, feedback, more info needed | |
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":"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":"feedback","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":"more info needed","color":"fbca04"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
# Duplicate, invalid, wont fix | |
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" | |
# Client, server | |
echo "POST https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" | |
curl --user "$USER:$PASS" --include --request POST --data '{"name":"client","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":"server","color":"e6e6e6"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels" |
This file contains 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 characters
Setup GitHub issue labels script |
@adambuczynski This did not work (got 401 Unauthorized responses), until I followed @stkent's suggestion above. With that fix in place, the script works as intended.
Thank you to the both of you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The line
should instead read