Skip to content
Latchkey

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-failure

In 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →