您可以使用 GitHub API 来实现此目的。创建一个 webhook 并按以下方式添加问题:
POST /repos/:owner/:repo/issues
示例来自https://developer.github.com/v3/issues/ https://developer.github.com/v3/issues/
{
"title": "Found a bug",
"body": "I'm having a problem with this.",
"assignee": "octocat",
"milestone": 1,
"labels": [
"Label1",
"Label2"
]
}
因此,您所要做的就是使用 HTTP - POST 命令来添加问题。
您可以使用 WebRequest 执行发布请求。
api的完整描述:https://api.github.com/repos/octocat/Hello-World/issues/1347 https://api.github.com/repos/octocat/Hello-World/issues/1347
完整的 C# 示例:
public void CreateBug(Exception ex) {
WebRequest request = WebRequest.Create ("https://api.github.com/repos/yourUserName/YourRepo/issues ");
request.Method = "POST";
string postData = "{'title':'exception occured!', 'body':'{0}','assignee': 'yourUserName'}";
byte[] byteArray = Encoding.UTF8.GetBytes (string.Format(postData,ex));
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream ();
dataStream.Write (byteArray, 0, byteArray.Length);
dataStream.Close ();
WebResponse response = request.GetResponse ();
}
现在您的问题已创建,并且响应包含来自 GitHub 的响应
这是“快速、简单”的解决方案。如果你想对 GitHub 问题做更多的事情,@VonC 的答案可能是更好的答案,因为它提供了一种更多与对象相关的解决方案