Last active
September 3, 2020 19:11
-
-
Save camilleriluke/89e57d7a5dd60e4425de039e05d3b1b6 to your computer and use it in GitHub Desktop.
Github repository labels standard
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
#!/usr/bin/env bash | |
# You can craete a token from https://github.com/settings/tokens and give the | |
# "repo" persmission to the token | |
AUTH_TOKEN=$1 | |
OWNERREPO=$2 | |
if [[ "$#" -ne 2 ]]; then | |
echo "Usage: $0 AUTH_TOKEN OWNER/REPO\n" | |
exit 1 | |
fi | |
echo "Updating labels for repository https://github.com/$OWNERREPO/labels" | |
echo "Removing default labels" | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" "https://api.github.com/repos/$OWNERREPO/labels/help%20wanted" | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" "https://api.github.com/repos/$OWNERREPO/labels/good%20first%20issue" | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/documentation | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/bug | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/duplicate | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/enhancement | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/invalid | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/question | |
curl --request DELETE -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels/wontfix | |
echo "Adding new labels" | |
curl --request POST --data '{"name": "Priority: Critical", "color": "d93f0b"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Priority: Low", "color": "efefef"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Priority: Medium", "color": "fbca04"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Status: On Hold", "color": "fef2c0"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Status: Review Needed", "color": "c5def5"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Status: WIP", "color": "ff6dbb"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Status: 🛳🇮🇹", "color": "c2e0c6"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Type: Bug", "color": "d4c5f9"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Type: New functionality", "color": "47f770"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Type: Refactoring", "color": "bd25c4"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels | |
curl --request POST --data '{"name": "Type: Maintenance", "color": "5319e7"}' -H "Authorization: token $AUTH_TOKEN" https://api.github.com/repos/$OWNERREPO/labels |
Works like a charm, but the name should probably be repo-labels.sh
You are right :) updated
Update: Added removal of good first issue
default label
Works great!
Small potential improvement, why not reading vars from command line:
...
AUTH_TOKEN=$1
# This could be your personal account or an org
OWNER=$2
REPO=$3
...
Thanks @lukKowalski. Script is now updated to be used like so:
Usage: repo-labels.sh AUTH_TOKEN OWNER/REPO
Update: Added removal of documentation
default label
Update: Removed label Type: Enhancement
and added Type: Refactoring
and Type: New functionality
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like a charm, but the name should probably be
repo-labels.sh
😄