Skip to content

Create pull requests for blog comments posted via a form (v3)

License

Notifications You must be signed in to change notification settings

Teknikaali/jekyll-blog-comments

 
 

Repository files navigation

Jekyll Blog Comments Azure Function

An Azure Function App that receives comment form posts and creates a pull request against your GitHub repository as part of the jekyll-blog-comments system.

The app includes just one function:

  • PostComment - receives form POST submission and creates a PR to add the comment to your Jekyll site

Customizations

This repository is a heavily modified version of the original:

  • Core functionality has been moved to a different project file making the PostComment just a thin passthrough layer
  • Heavily uses Dependency Injection to make code more testable
  • Adds xUnit unit test and code coverage reporting with Coverlet + ReportGenerator
  • Automatically deploy to Azure

Code coverage status

Branch coverage Line coverage

Coverage reports are located in the gh-pages branch. Click the badge to see the full coverage report.

Setup

To set this up, you'll need to have an Azure Portal account.

  1. Fork this repository
  2. Create a v3 Azure Function
  3. Create subscription key in Microsoft Azure Recognition optional
  4. Set up your function to deploy from your fork
  5. Set up the following App Settings for your Azure Function
Setting Value Required
PullRequestRepository owner/name of the repository that houses your Jekyll site for pull requests to be created against. For example, haacked/haacked.com will post to https://github.com/haacked/haacked.com *
GitHubToken A GitHub personal access token with access to edit your target repository. *
Website The URL to the website that hosts the comments. This is used to make sure the correct site is posting comments to the receiver. *
FallbackCommitEmail The email address to use for GitHub commits and PR's if the form does not supply one.
TextAnalyticsSubscriptionKey Subscription Key for Microsoft Azure Recognition, if you don't want to use, just leave empty.
TextAnalyticsRegion Region for your Subscription key (E.g.: westus)
TextAnalyticsLanguage Language for comment, find lang code here

Local development

  • You'll need to add local.settings.json to JekyllBlogCommentsAzure project as it is excluded from Git with .gitignore. ** Example of local.settings.json:
{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "Website": "https://example.com",
    "FallbackCommitEmail": "redacted@example.com",
    "GitHubToken": "TestToken",
    "PullRequestRepository": "YourAlias/yourRepository"
  }
}

Note: with this example configuration you can't commit/push because of the invalid GitHub token.

  • Run/Debug JekyllBlogCommentsAzure project
  • You can test in local environment by using Postman (or similar REST client) ** Local Postman environment and an example collection has been provided inside Postman-folder

About

Create pull requests for blog comments posted via a form (v3)

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.6%
  • Batchfile 0.4%