https://github.com/alexellis/sponsors-functions
GitHub Sponsors webhook receiver and Discord forwarder
https://github.com/alexellis/sponsors-functions
github hmac nodejs openfaas sponsors webhooks
Last synced: 5 months ago
JSON representation
GitHub Sponsors webhook receiver and Discord forwarder
- Host: GitHub
- URL: https://github.com/alexellis/sponsors-functions
- Owner: alexellis
- Created: 2020-02-08T12:35:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-15T12:04:25.000Z (6 months ago)
- Last Synced: 2025-04-15T12:44:53.330Z (6 months ago)
- Topics: github, hmac, nodejs, openfaas, sponsors, webhooks
- Language: JavaScript
- Homepage: https://github.com/sponsors/alexellis/
- Size: 154 KB
- Stars: 33
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sponsors-functions
GitHub Sponsors webhook receiver and Discord forwarder, written in Node.js
[](https://opensource.org/licenses/MIT)
[](https://www.openfaas.com)This function is hosted on [faasd](https://github.com/openfaas/faasd).
Subscribe to my Insiders Updates by Sponsoring me via GitHub:
* 🐳 [Sponsor now](https://github.com/sponsors/alexellis/)
* ⭐️ Show support and [Star OpenFaaS](https://github.com/openfaas/faas)## Usage
This function receives and validates a webhook from [GitHub Sponsors](https://github.com/sponsors) using the [node12 template](https://github.com/openfaas/templates/) from [OpenFaaS](https://github.com/openfaas/).
Each message is verified using the [crypto library](https://nodejs.org/api/crypto.html) and HMAC.
Messages that pass HMAC are then sent over to a secret webhook URL and appear in Discord
It is triggered by any event from [GitHub Sponsors](https://github.com/sponsors/alexellis)
There's a switch statement on each event, which sends send a "pretty" string such as Person X just sponsored you, or Person X cancelled their sponsorship including an appropriate emoticon for the action taken by the user.

## Deployment
You can pick between [self-hosted OpenFaaS](https://github.com/openfaas/faas) or [OpenFaaS Cloud](https://github.com/openfaas/openfaas-cloud).
### With OpenFaaS Cloud
* Fork the repo
* [Add OpenFaaS Cloud integration to your repo, the community cluster](https://github.com/openfaas/community-cluster) is free to use for hosting.
* Create a channel and add an [incoming webhook integration on Slack](https://api.slack.com/messaging/webhooks)
* Create the webhook on GitHub for your URL and enter a webhook secret
* Seal your own secrets, change `alexellis` for your own username.
```sh
export WEBHOOK=""
export SLACK=""faas-cli cloud seal --name alexellis-sponsors \
--literal webhook-secret=$WEBHOOK \
--literal slack-url=$SLACK
```* Fire a test event from your sponsors page
### With OpenFaaS or faasd
You can also host a simpler version of OpenFaaS and deploy the function there:
* [OpenFaaS on Kubernetes](https://docs.openfaas.com/deployment/#kubernetes-recommended-for-production-and-for-work)
* [OpenFaaS with containerd (faasd)](https://docs.openfaas.com/deployment/#faasd-with-containerd)
See also: [SponsorshipEvent](https://developer.github.com/v3/activity/events/types/#sponsorshipevent)