An open API service indexing awesome lists of open source software.

https://github.com/distantcam/openfaas-githubapp-example


https://github.com/distantcam/openfaas-githubapp-example

Last synced: 12 months ago
JSON representation

Awesome Lists containing this project

README

          

# OpenFaaS GitHub App Example

A sample OpenFaaS function that acts as a GitHub App written in .NET Core.

The boilerplate code for this example is based on [GitHubCoreReceiver](https://github.com/aspnet/AspLabs/tree/master/src/WebHooks/samples/GitHubCoreReceiver) with JWT token authentication based on [Working with GitHub Apps](https://octokitnet.readthedocs.io/en/latest/github-apps/) in the Octokit.net documentation.

## Installation

[OpenFaaS](https://www.openfaas.com/) and [faas-cli](https://docs.openfaas.com/cli/install/) need to be installed first.

- Spin up an ngrok forwarder using the following.

```
docker run -p 4040:4040 -d --rm --name=ngrok --net=func_functions alexellis2/ngrok-admin http gateway:8080
```

- Go to http://127.0.0.1:4040/ and copy the ngrok address.

- [Register a GitHub App](https://developer.github.com/apps/building-your-first-github-app/#register-a-new-app-with-github). The sample requires Read & Write access for Issues and a subscription to Issues events. When testing the ngrok URL (like https://abcdef.ngrok.io/function/github) should be used for the URL fields.

- Download the private key and you also need the Application ID.

- Copy `env.example.yml` to `env.yml` and fill in the values. The Webhook secret needs to be at least 16 characters.

```yaml
environment:
GH_SecretKey: 0123456789012345
GH_ApplicationId: 12345
GH_PrivateKey: "abcdef\nghijkl"
```

- Pull down the OpenFaaS template for this function

```
faas-cli template pull https://github.com/distantcam/csharp-webrequest-template
```

- Build and Deploy the project to OpenFaas

```
faas-cli build && faas-cli deploy
```