Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apotek/17254f4610cca5d0e555 to your computer and use it in GitHub Desktop.
Save apotek/17254f4610cca5d0e555 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: "
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"
# 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"
Setup GitHub issue labels script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment