An ASP.NET Core webhook for automatically responding to GitHub issues and PRs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DocImages
Responder
Shared
Webhook
.editorconfig
.gitignore
GitHubAutoresponder.csproj
Program.cs
README.md
Startup.cs
appsettings.Development.json
appsettings.json

README.md

GitHub Autoresponder

An ASP.NET Core webhook for automatically responding to GitHub issues and PRs.

Demo screen capture

Try Me!

Open an issue against this repository to receive an automated response.

Setup

  • Install .NET Core
  • git clone https://github.com/jamesseanwright/github-autoresponder.git
  • cd github-autoresponder
  • dotnet restore

Then one can run:

  • dotnet xunit - execute the unit tests
  • dotnet start - start the server

The sole exposed endpoint can be found at /api/webhook, which:

Environment Variables

This service requires two environment variables to function:

GHAR_SECRET

The secret token specified when registering the webhook in your repository's settings.

GHAR_CREDENTIALS

A Base64-encoded string following a <responding_username>:<personal_api_token> format e.g. "jamesseanwright:somerandomsha1"

  • responding_username - the username used to respond to issues and PRs
  • personal_api_token - the personal API token to be used, along with the username, to authenticate requests made to the GitHub API
    • Note that the only required scope is public_repo

Registering the Webhook Against a Repository

Registering a webhook

  1. Go to one of your repositories
  2. Click Settings
  3. Click Webhooks
  4. In Payload URL, enter the absolute URL via which the webhook can be accessed, including the /api/webhook path
  5. Select application/json from the Content type dropdown
  6. Enter the webhook secret that you most likely generated in the previous section (see GHAR_SECRET)
  7. Under Which events would you like to trigger this webhook?, choose Let me select individual events, and select: Issues; and Pull request
  8. Click Add webhook to complete the registration

Changing the Response Message

Currently, the response message is a hard-coded string that lives in the ResponseFactory class. Eventually, this will be separated into a Markdown file to be read at startup.