Mirror of space-wizards/SS14.Labeller
Find a file
Fildrance ba2e32cf09
Feature/http client retry policy for gh api client (#9)
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-09-27 22:21:28 +02:00
.github/workflows ci: Revert docker builds to compile inside the container 2025-08-07 00:10:52 +02:00
SS14.Labeller Feature/http client retry policy for gh api client (#9) 2025-09-27 22:21:28 +02:00
SS14.Labeller.Tests Feature/http client retry policy for gh api client (#9) 2025-09-27 22:21:28 +02:00
.gitignore Slightly refactor the gh webhook endpoint and middleware (#12) 2025-09-27 22:19:20 +02:00
appsettings.json.example Add option to disable Discourse integration 2025-08-05 18:24:07 +02:00
docker-compose.yml refactor: Allow specifying connection string 2025-08-06 23:00:44 +02:00
Dockerfile ci: Revert docker builds to compile inside the container 2025-08-07 00:10:52 +02:00
global.json Add project files 2025-06-28 00:33:06 +02:00
LICENCE.txt Move licence and readme files (i took stupid sauce today) 2025-06-28 00:35:53 +02:00
README.md docs: Cleanup readme 2025-08-05 18:25:54 +02:00
SS14.Labeller.sln refactor: re-organization of files, changed event handling to dispatcher pattern, networked message to strong-typed stuff (#1) 2025-08-03 12:23:16 +02:00

SS14.Labeller

Simple ASP.NET NativeAOT application for labelling our content repository

Usage

Create the a file called appsettings.json like so:

{
  "GitHub": {
    "WebhookSecret": "mysecret",
    "Token": "github_pat_AAAA"
  },
  "Discourse": {
    "Enable": false,
    "ApiKey": "---",
    "Username": "---",
    "DiscussionCategoryId": 0,
    "Url": "https://forum.example.com/"
  }
}

All of these values must be set for the application to function.

To set the port, use the ASPNETCORE_URLS environment variable, e.g. ASPNETCORE_URLS=http://localhost:5000.

Config File Reference

GitHub

WebhookSecret: The secret you set for your webhook.
Token: A GitHub PAT token.

Discourse

Enable: Whether to enable the discourse integration. If false, you can leave the rest unset.
ApiKey: An API key for Discourse. Follow these docs for how to get one.
Username: The username to use for Discourse.
DiscussionCategoryId: What category to send new discussion Topics in. You can get this by opening the Topic in your browser and the number in the URL is the category ID.
Url: The Forum URL. Must end with a trailing slash.

Building

To build the application, use the following command:

dotnet publish ./SS14.Labeller -c Release -r <platform ex. win-x64> --self-contained true /p:PublishAot=true

Running the application is just like any other executable. On Unix systems, you may need to set the executable bit on the binary.

For setting up the GitHub webhook, follow the instructions in the GitHub documentation. This app requires the Pull request reviews, Pull requests and Issues events to be enabled. The webhook URL should point to the URL where the application is running, e.g. http://localhost:5000/webhook.

The token must have the Issues and Pull requests scopes enabled for read and write access.

Testing and debug

You will need set up proxy for messages from GitHub to your local machine. For that you can use https://smee.io

  1. Install Smee cli using npm (if you don't have it - follow those instructions here)
    npm install --global smee-client
  2. Visit https://smee.io, click 'Start a new channel' and copy the link that will be generated.
  3. In your console use Smee cli to start proxy forwarding to your local machine
    smee -u https://smee.io/{place-you-channel-code-here} -t http://127.0.0.1:5000/webhook

Upon launching, it will output line like

Forwarding https://smee.io/{place-you-channel-code-here} to http://127.0.0.1:5000/webhook

That means that every message it receives, including

  • Its payload
  • Its headers

will be proxied to http://127.0.0.1:5000/webhooks.

The labeller should already automatically start on port 5000, but if it doesn't you can use this launchProfile.json

{
  "profiles": {
    "SS14.Labeller": {
      "commandName": "Project",
      "launchBrowser": false,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:5000"
    }
  }
}

Now we need set up the repository. Create new repository or use an existing one.

  1. Go to the 'Settings' tab of repository, then to 'Webhooks' (https://github.com/{owner}/{repository}/settings/hooks)
  2. Click 'Add webhook'
  3. Copy your smee.io url into Payload URL field
  4. Select content-type application/json
  5. Input any "secret" word or phrase into the Secret field.
  6. In the block 'Which events would you like to trigger this webhook?' select 'Let me select individual events' and check the events as listed in the Usage section.