You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature or problem you’d like to solve
I would like the ability to create new labels.
I am using gh to script populating starter issues on new repositories, and currently it appears one can only assign labels that already exist. Since this is for a new repository, I'd like the ability to also script creating the labels in order to tag the new issues with them.
Proposed solution
New subcommand like gh label create [flags] that works similarly to how it works for issues and pull requests.
The api command didn't work for me - I guess it does not work well with GitHub Enterprise. I worked around using plain curl, but it does not look as nice as it could with the GitHub CLI.
@alterrebe If you remove the --silent flag, do you get some response back? Also you may add the -i flag to see response headers. If this doesn't work on Enterprise (it absolutely should), please send us more debugging info so we can fix this 🙇
Note that for Enterprise you need to set GH_HOST for now:
GH_HOST=example.com gh api repos/:owner/:repo/labels ...
Note that for Enterprise you need to set GH_HOST for now:
GH_HOST=example.com gh api repos/:owner/:repo/labels ...
This is the point I missed. Other commands work w/o it (I guess they autodetect the GH_HOST from the .git/config of the current repository, but gh api doesn't do it).
Activity
mislav commentedon Aug 11, 2020
Thanks for the suggestion! You can do so right now with the api command:
Note that the
colorparameter is required.alterrebe commentedon Oct 12, 2020
The
apicommand didn't work for me - I guess it does not work well with GitHub Enterprise. I worked around using plain curl, but it does not look as nice as it could with the GitHub CLI.mislav commentedon Oct 15, 2020
@alterrebe If you remove the
--silentflag, do you get some response back? Also you may add the-iflag to see response headers. If this doesn't work on Enterprise (it absolutely should), please send us more debugging info so we can fix this 🙇Note that for Enterprise you need to set GH_HOST for now:
vl4py commentedon Nov 27, 2020
If you go for this feature, would it be possible to also do it from the
interactivemode?Therefore, when creating pr instead of only allowing to search among the existing ones, you could create one straight forward?
alterrebe commentedon Nov 27, 2020
This is the point I missed. Other commands work w/o it (I guess they autodetect the
GH_HOSTfrom the.git/configof the current repository, butgh apidoesn't do it).Thank you, it resolved my problem.
billygriffin commentedon Mar 2, 2021
I'm closing this as a duplicate of #446 - sorry for missing that the first time around, and please follow along there.
mishabruml commentedon Apr 5, 2022
gh api repos/:owner/:repo/labels/my-label-name -X GET --silent || gh api repos/:owner/:repo/labels -f name="my-label-name" -f color="1D76DB" --silentThis works OK for me for now (for an automated script) 😄
mishabruml commentedon Apr 5, 2022
actually as of #5316 you can now do:
gh api repos/:owner/:repo/labels/my-label-name -X GET --silent || gh label create my-label-name -c "1D76DB" -d "my label description"