gh issue create Command Reference
Open a GitHub issue from the command line, non-interactively.
gh issue create opens an issue in a repository. In CI it is used to file automated reports, such as opening a tracking issue when a scheduled job fails.
What it does
gh issue create opens an issue with a title, body, labels, assignees, and milestone. Without flags it prompts; in automation you supply everything so it runs cleanly and prints the new issue URL.
Common flags and usage
- --title / --body / --body-file: issue title and description
- --label / --assignee / --milestone: apply metadata
- --repo OWNER/REPO: target a specific repository
- --project: add the issue to a project
Example
shell
- name: File failure issue
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue create --title "Nightly job failed: run ${{ github.run_id }}" \
--body "See the workflow logs for details." --label ci-failureIn CI
Gate the step on if: failure() so it only files an issue when the job fails. Provide --title and --body so the command never prompts in a headless runner.
Key takeaways
- Provide --title and --body so issue creation never prompts.
- Combine with if: failure() to auto-file issues on job failure.
- --label and --assignee route the issue to the right people.
Related guides
gh pr create Command ReferenceReference for gh pr create in CI/CD: open a pull request non-interactively with title, body, base, and labels…
gh api Command ReferenceReference for gh api in CI/CD: call any REST or GraphQL endpoint with authentication handled, pass fields, pa…
gh run watch Command ReferenceReference for gh run watch in CI/CD: stream a workflow run until it finishes and exit nonzero on failure, so…