Skip to content

space-wizards/SS14.Labeller

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •