gh label create: Create Issue Labels in CI
gh label create adds a new issue or pull request label with an optional color and description.
Repo bootstrap and triage automation create the labels they rely on; --force makes the step safe to re-run.
What it does
gh label create adds a label to the repository. You set the name, an optional hex --color, and a --description. --force updates the label if it already exists instead of failing, making the command idempotent.
Common usage
gh label create bug --color FF0000 --description "Something is broken"
gh label create needs-review --color "#0E8A16"
gh label create release --color B60205 --forceFlags
| Flag | What it does |
|---|---|
| -c, --color <hex> | Label color as a hex code (with or without #) |
| -d, --description <text> | Label description |
| -f, --force | Update the label if it already exists |
| -R, --repo <owner/repo> | Target a specific repository |
In CI
Set GH_TOKEN and permissions: { issues: write }. Use --force in bootstrap scripts so re-running the job does not error on labels that already exist. Color accepts a bare hex like FF0000 or a quoted #-prefixed value.
Common errors in CI
"HTTP 422: Validation Failed (label already exists)" means the label is present; add --force to update instead. "Resource not accessible by integration" means the token lacks issues: write. An invalid color string also raises an HTTP 422 validation error.