Skip to content

Instantly share code, notes, and snippets.

@youzi
Last active May 19, 2021 15:14
Show Gist options
  • Save youzi/d43068db2f5fd5d40b20 to your computer and use it in GitHub Desktop.
Save youzi/d43068db2f5fd5d40b20 to your computer and use it in GitHub Desktop.
Create milestone and labels script
#!/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
curl --user "$USER:$PASS" --include --request 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/duplicate"
curl --user "$USER:$PASS" --include --request 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/help%20wanted"
curl --user "$USER:$PASS" --include --request 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/question"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels/wontfix"
# Create labels
# team
curl --user "$USER:$PASS" --include --request POST --data '{"team": "frontend","color":"00FFB7"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"team": "backend","color":"FF0048"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"team": "native","color":"C7FF00"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
# priority
curl --user "$USER:$PASS" --include --request POST --data '{"name":"prio: critical","color":"b60205"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"prio: high","color":"5319e7"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"prio: low","color":"009800"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
# status
curl --user "$USER:$PASS" --include --request POST --data '{"name":"status: in-progress","color":"bfdadc"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"status: pending","color":"c7def8"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"status: resolved","color":"bfe5bf"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"status: testing","color":"bfd4f2"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
# type
curl --user "$USER:$PASS" --include --request POST --data '{"name":"type: bug","color":"fc2929"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"type: enhancement","color":"006b75"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"type: feature","color":"eb6420"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
curl --user "$USER:$PASS" --include --request POST --data '{"name":"type: question","color":"cc317c"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/labels"
# standard milestones
curl --user "$USER:$PASS" --include --request POST --data '{"title":"Backlog"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/milestones"
curl --user "$USER:$PASS" --include --request POST --data '{"title":"Icebox"}' "https://api.github.com/repos/$REPO_USER/$REPO_NAME/milestones"
@ninjatux
Copy link

looks good!

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