https://github.com/weakky/graphql-boilerplate-lambda-sync
A lambda function to synchronize graphql-boilerplates
https://github.com/weakky/graphql-boilerplate-lambda-sync
Last synced: 10 months ago
JSON representation
A lambda function to synchronize graphql-boilerplates
- Host: GitHub
- URL: https://github.com/weakky/graphql-boilerplate-lambda-sync
- Owner: Weakky
- Created: 2018-03-28T23:27:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-28T23:39:33.000Z (about 8 years ago)
- Last Synced: 2025-03-29T06:11:13.352Z (about 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serverless Github webhook listener
This service will listen to github webhooks fired by a given repository.
## Use Cases
* Custom github notifications
* Automatically tagging github issues
* Pinging slack on new Pull requests
* Welcoming new stargazers
* etc.
## How it works
```
┌───────────────┐ ┌───────────┐
│ │ │ │
│ Github repo │ │ Github │
│ activity │────Trigger───▶│ Webhook │
│ │ │ │
└───────────────┘ └───────────┘
│
┌────POST────────┘
│
┌──────────▼─────────┐
│ ┌────────────────┐ │
│ │ API Gateway │ │
│ │ Endpoint │ │
│ └────────────────┘ │
└─────────┬──────────┘
│
│
┌──────────▼──────────┐
│ ┌────────────────┐ │
│ │ │ │
│ │ Lambda │ │
│ │ Function │ │
│ │ │ │
│ └────────────────┘ │
└─────────────────────┘
│
│
▼
┌────────────────────┐
│ │
│ Do stuff │
│ │
└────────────────────┘
```
## Setup
1. Set your webhook secret token in `serverless.yml` by replacing `REPLACE-WITH-YOUR-SECRET-HERE` in the environment variables `GITHUB_WEBHOOK_SECRET`.
```yml
provider:
name: aws
runtime: nodejs6.10
environment:
GITHUB_WEBHOOK_SECRET: REPLACE-WITH-YOUR-SECRET-HERE
```
2. Deploy the service
```
export AWS_ACCESS_KEY_ID=__YOUR_AWS_ACCESS_KEY__
export AWS_SECRET_ACCESS_KEY=__YOUR_AWS_SECRET_KEY__
```
```yaml
serverless deploy
```
After the deploy has finished you should see something like:
```bash
Service Information
service: github-webhook-listener
stage: dev
region: us-east-1
api keys:
None
endpoints:
POST - https://abcdefg.execute-api.us-east-1.amazonaws.com/dev/webhook
functions:
github-webhook-.....github-webhook-listener-dev-githubWebhookListener
```
3. Configure your webhook in your github repository settings. [Setting up a Webhook](https://developer.github.com/webhooks/creating/#setting-up-a-webhook)
**(1.)** Plugin your API POST endpoint. (`https://abcdefg.execute-api.us-east-1.amazonaws.com/dev/webhook` in this example). Run `sls info` to grab your endpoint if you don't have it handy.
**(2.)** Plugin your secret from `GITHUB_WEBHOOK_SECRET` environment variable
**(3.)** Choose the types of events you want the github webhook to fire on

4. Manually trigger/test the webhook from settings or do something in your github repo to trigger a webhook.
You can tail the logs of the lambda function with the below command to see it running.
```bash
serverless logs -f githubWebhookListener -t
```
You should see the event from github in the lambda functions logs.
5. Use your imagination and do whatever you want with your new github webhook listener! 🎉
Let us know if you come up with a cool use case for this service =)