Skip to content

Instantly share code, notes, and snippets.

@mavvverick
Last active April 6, 2022 17:56
Show Gist options
  • Save mavvverick/9b6c5d06db253f8f16a85315069fb019 to your computer and use it in GitHub Desktop.
Save mavvverick/9b6c5d06db253f8f16a85315069fb019 to your computer and use it in GitHub Desktop.
Add sane labels to GitHub Repo
USER={{user}} or {{organisation}}
TOKEN={{token}}
REPO={{repo}}
#Delete default labels
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/bug"
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/duplicate"
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/enhancement"
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/invalid"
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/question"
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/wontfix"
curl --user "$USER:$TOKEN" --include --request DELETE "https://api.github.com/repos/$USER/$REPO/labels/documentation"
# Create labels
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Abandoned","color":"000000"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Accepted","color":"009800"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Available","color":"bfe5bf"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Blocked","color":"e11c21"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Completed","color":"006b75"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: In Progress","color":"cccccc"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: On Hold","color":"e11c21"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Pending","color":"fef2c0"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Review Needed","color":"fbca04"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Status: Revision Needed","color":"e11c21"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Type: Enhancement","color":"84b6eb"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Type: Bug","color":"e11c21"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Type: Maintenace","color":"fbca04"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Type: Question","color":"cc317c"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Priority: Critical","color":"e11c21"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Priority: High","color":"eb641f"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Priority: Low","color":"009800"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"Priority: Medium","color":"fbca04"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"duplicate","color":"aaaaaa"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"wishlist","color":"66Aa00"}' "https://api.github.com/repos/$USER/$REPO/labels"
curl --user "$USER:$TOKEN" --include --request POST --data '{"name":"declined","color":"83000C"}' "https://api.github.com/repos/$USER/$REPO/labels"
@mavvverick
Copy link
Author

Usage:

  1. Download file
  2. Add USER or organisation
  3. Add Personal Access Token
  4. Add Repo name
  5. Add file permission in command line: chmod +x labels.sh
  6. ./labels.sh

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