How to create a GitHub issue from within R?

Viewed 156

Is there a way to create a GitHub issue from within R? I had a look at the GitHub API documentation. There is an endpoint for creating issues but I'm not sure how to translate that into R code.

1 Answers

If your username is user and you have a repository called my-repo, then this code will create a new issue with the specified title and body text in the repo.

gh::gh(
  endpoint = "POST /repos/user/my-repo/issues",
  title = "Issue title",
  body = "Some text"
)

In order for this to work you need a GitHub access token. Once you created one make sure to add it to .Renviron, e.g. using usethis::edit_r_environ().

If you are using GitHub Enterpise then you will have to set the .api_url argument of gh::gh().

Related