Giter Club home page Giter Club logo

githubappdotnetsample's Introduction

GitHubAppDotnetSample

Build Status Release

A sample GitHub App written in .NET Core with Azure Pipelines for build and deploy.

The boilerplate code for this example is based on GitHubCoreReceiver with JWT token authentication based on Working with GitHub Apps in the Octokit.net documentation.

Installation

To test locally:

  • Clone the repository.
  • Go to https://smee.io and click Start a new channel.
  • Install the client:
npm install --global smee-client
smee -u https://smee.io/qrfeVRbFbffd6vD -P /api/webhooks/incoming/github
  • You should see output like the following:
Forwarding https://smee.io/qrfeVRbFbffd6vD to http://127.0.0.1:3000/api/webhooks/incoming/github
Connected https://smee.io/qrfeVRbFbffd6vD
  • Register a GitHub App. The sample requires Read & Write access for Issues and a subscription to Issues events. When testing the smee URL (like https://smee.io/qrfeVRbFbffd6vD) should be used for the URL fields.
  • Download the private key and you also need the Application ID.
  • Add the following configuration settings in an appsettings.json like for example apsettings.Development.json. The Webhook secret needs to be at least 16 characters.
{
  "WebHooks:GitHub:SecretKey:default": "0123456789012345",
  "GitHubApp:ApplicationId": 19892,
  "GitHubApp:PrivateKey:file": "path/to/your/private-key.pem"

}
  • Start the GitHubAppDotnetSample GitHub App
dotnet run

Private key settings

There are three ways to add the private key:

  • GitHubApp:PrivateKey:file
    • As a local path to the private key file
  • GitHubApp:PrivateKey:string
    • As a string value. You can replace new lines using: awk '{printf "%s\\n", $0}' path/to/your/private-key.pem
  • GitHubApp:PrivateKey:base64
    • As a Base64 encoded string using fo example: cat path/to/your/private-key.pem | openssl base64 | pbcopy

githubappdotnetsample's People

Contributors

bas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

githubappdotnetsample's Issues

Typo

In Filters/CreateGitHubClientFilter.cs, in line 54, the variable "privateKeyBae64"

Validate security for configuration settings

Currently the appsettings.json is used for the configuration settings including the app id and path to the private key. There must be a better and may be more portable way of storing this information.

Add more detailed instructions

For those who are less familiar with GitHub Apps it might be useful to provide more detailed instructions for installation, configuration and adding features.

Validate JWT token and app client generation

Currently the JWT token and app client are created in the constructor of the Controller class. There must be a better place for this logic like may be in a Filter, service or Helper externalized from the Controller to make it more reusable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.