Last active
October 22, 2022 10:47
-
-
Save adiberr/f9771452b2be61558a2380b2ba6f105d to your computer and use it in GitHub Desktop.
Simple script for creating labels in GitLab
This file contains hidden or 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/sh | |
| # Author: Adib Err (@adiberr) | |
| # GitLab Docs: https://docs.gitlab.com/ee/api/labels.html#create-a-new-label | |
| PROJECT_ID= # Your project id | |
| GITLAB_API="https://gitlab.com/api/v4/projects/${PROJECT_ID}/labels" | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: mklabel <label> <color>" | |
| exit 1 | |
| fi; | |
| NAME=$(echo $1 | sed -e 's/_/%20/g') | |
| COLOR=$(echo $2 | sed -e 's/#/%23/') | |
| curl -s -o /dev/null -w '%{http_code}\n' --data "name=${NAME}&color=${COLOR}" --header "PRIVATE-TOKEN: $(cat token.txt)" "${GITLAB_API}" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to insert multiple labels at once :