https://github.com/distantcam/openfaas-githubapp-example
https://github.com/distantcam/openfaas-githubapp-example
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/distantcam/openfaas-githubapp-example
- Owner: distantcam
- Created: 2018-12-21T06:19:25.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-21T06:46:35.000Z (over 7 years ago)
- Last Synced: 2025-03-04T19:37:42.835Z (over 1 year ago)
- Language: C#
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```