Skip to content

non-interactive issue create with template #7405

Description

@Gray-Wind

Describe the feature or problem you’d like to solve

I am trying to create a special templated issue from the CI with some checklists on release. We have already set up templates, which we are using now manually, but it would be really good to open them automatically.

With gh I can create a templated issue with gh issue create -T "template name" --title "some title" and it asks me to modify body (I do not want to do so, it is just a checklist to deal with it later). Also it asks what to do upon creation (add metadata, open in browser), which should be possible to skip.

Proposed solution

The last confirmation step is called submit, the option could have the same name to reflect the action.

Full CI command will look like

gh issue create --template "template name" --title "issue title" --submit

Activity

  1. samcoe commented on May 7, 2023

    @samcoe
    Contributor

    @Gray-Wind The --fill option for pr create command populates a pull request title and body with information from git commits, what would you suggest we fill the the issue title and body with in this case since there are no git commits associated with an issue?

  2. added
    more-info-neededMore info needed from user/contributor
    and removed on May 7, 2023
  3. Gray-Wind commented on May 8, 2023

    @Gray-Wind
    Author

    Okay, got it, what I suggest, is to keep the body from the template itself. The title should be provided with the gh tool.

    The option could have a different name, for instance, it could be --submit, which is aligned with interactive options.

  4. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    and removed
    more-info-neededMore info needed from user/contributor
    on May 8, 2023
  5. added
    coreThis issue is not accepting PRs from outside contributors
    and removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on Jun 12, 2023
  6. vilmibm commented on Jun 12, 2023

    @vilmibm
    Contributor

    I think what @Gray-Wind tried to run is perfectly reasonable and should work non-interactively. This is related to #7575 , though, so I think instead of acting on this issue specifically we should roll it into the wider UX improvements we want for pr/issue create.

  7. Levdbas commented on May 27, 2024

    @Levdbas

    Any word on when this will be implemented? Would be great to create tickets via cli without interaction!

  8. gustafedn commented on May 28, 2024

    @gustafedn

    I too am having the same issue!

  9. markfullmer commented on Apr 3, 2026

    @markfullmer

    As workaround for non-interactively creating an issue from a template, I am using the --body-file parameter, and adding a helper function to parse the contents of the desired template, stripping out the frontmatter:

    template-body-file() {
      TEMPLATE_PATH=".github/ISSUE_TEMPLATE/<FILENAME>.md"
      local BODY_FILE
      BODY_FILE=$(mktemp)
      # Remove the issue template front matter and keep only the Markdown body.
      awk '
        NR == 1 && $0 == "---" { in_front_matter = 1; next }
        in_front_matter && $0 == "---" { in_front_matter = 0; next }
        !in_front_matter { print }
      ' "$TEMPLATE_PATH" > "$BODY_FILE"
      printf "%s\n" "$BODY_FILE"
    }
    
    BODY_FILE=$(template-body-file)
    
    gh issue create \
      --repo "$ORG/$REPO" \
      --title "<TITLE>" \
      --body-file "$BODY_FILE" \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-issuerelating to the gh issue command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions