2

I want to create github issues from the command line, using something like :
https://cli.github.com/manual/gh_issue_create
or
https://docs.github.com/en/rest/reference/issues#create-an-issue
but I can't find a way to do it and add attachments to the issue.

If I add the issue through the website, the files are added to the repo, and then a link to the is created in the following format:
(filename)[link-to-the-file]
and the link-to-the-file looks something like this:
https://github.com/username/repo-name/files/x/file-name

So I suppose that if I add the file to the repo under files/ then I will be able to reference it with the right format, then my question is how can I add a file to a github repo, and then get the link to that file, from the command line to be able to attach it to an issue?

hra1234
  • 401
  • 4
  • 11
  • I'm not certain about this, so just comments instead of an answer. The GitHub CLI uses the API under the hood, so if the API can't do it, then the CLI can't. If the API *can* do it, then the CLI might have a nice command for it (like `gh issue create`), or else you can always use `gh api` to talk to the API directly while `gh` takes care of auth, headers and so on. – Benjamin W. Jun 30 '21 at 16:06
  • 1
    For file creation of the sort that happens when you drag and drop a file into an issue ([described here](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/attaching-files)), I don't think the API supports it, see [this thread](https://github.community/t/attach-a-file-during-issue-creation/141381). However, you can [separately upload a file](https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents) and then reference it in the issue, but it's not exactly the same result as when drag-and-dropping. – Benjamin W. Jun 30 '21 at 16:07
  • 2
    It's arguably better, though, because the file will have the same permissions as the repository, and not be accessible to anybody with the link as a file created during issue creation would be. – Benjamin W. Jun 30 '21 at 16:08

0 Answers0