OpenFaaS CRUD sample with a Postgres backend and GitHub emojis as input.
MIT License
This is a serverless CRUD sample project with Postgres and GitHub emoji integration. You can use it to tally up the emojis used in various comments across your GitHub projects.
This sample uses the OpenFaaS golang-middleware template and three endpoints:
You can see the results in the demo below. Feel free to try it out, if the endpoint is still up.
The code is adapted from the Serverless Single Page App - aka Open Source leaderboard
Example output view the /view
function:
Example input from a GitHub issue and webhook:
You can use DigitalOcean managed Postgres for example.
psql postgresql://connection-string here
Paste in schema.sql
export USERNAME=""
export PASSWORD=""
export HOST=""
export WEBHOOK_SECRET=""
faas-cli secret create username --from-literal $USERNAME
faas-cli secret create password --from-literal $PASSWORD
faas-cli secret create host --from-literal $HOST
faas-cli secret create webhook-secret --from-literal $WEBHOOK_SECRET
# Get the additional template
faas-cli template store pull golang-middleware
# Deploy
faas-cli deploy
sed -i stack.yml s/alexellis2/your-docker-hub/g
export DOCKER_BUILDKIT=1
faas-cli up --tag=sha
Go to Settings for your repo and click "Webhooks"
Add a webhook
Pick only the issue comments event, there is no issue for reactions at this time.
Now have someone send a comment to one of the issues in your repo with an emoji i.e. 👍
If you need to create a HTTP tunnel to your local computer, try inlets and inletsctl
View the result on the /view
function.
If you are using Crossplane to get yourself a Postgresql DB: start here