Exemplo n.º 1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            log.LogInformation($"Request body {requestBody}");

            dynamic data = JsonConvert.DeserializeObject(requestBody);

            string refType   = data?.ref_type;
            string reference = data.@ref;

            if (IsMasterBranch(refType, reference))
            {
                string owner          = data.repository.owner.login;
                string repositoryName = data.repository.name;

                await GitHubManager.ConfigureBranchProtections(owner, repositoryName, "master");
            }

            string message = $"message received {requestBody}";

            return(new OkObjectResult(message));
        }