Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active April 1, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/e3ed9363bf2d44dc4a1ecb37a1cb5927 to your computer and use it in GitHub Desktop.
Save guitarrapc/e3ed9363bf2d44dc4a1ecb37a1cb5927 to your computer and use it in GitHub Desktop.
#r "Newtonsoft.Json"
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
var jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
if (data.comment == null || data.comment.body == null) {
return req.CreateResponse(HttpStatusCode.BadRequest, new {
error = "Please pass comment:body properties in the input object"
});
}
log.Verbose($"GitHub WebHook triggered!, {data}");
var message = $@"New GitHub comment posted by {data.comment.user.login} at {data.repository.name},
Url : {data.comment.url}
Tite : {data.issue.title}
-----
{data.comment.body}";
return req.CreateResponse(HttpStatusCode.OK, new {
body = message
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment