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
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
Coverage reports are located in the gh-pages branch. Click the badge to see the full coverage report.
To set this up, you'll need to have an Azure Portal account.
- Fork this repository
- Create a v3 Azure Function
- Create subscription key in Microsoft Azure Recognition optional
- Set up your function to deploy from your fork
- 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 |
- You'll need to add
local.settings.json
toJekyllBlogCommentsAzure
project as it is excluded from Git with .gitignore. ** Example oflocal.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