This folder contains the source for a Cloud Function implementing a GitHub WebHook endpoint which can react to issues being labeled and send notifications to subscribers.
To run local tests use test.sh
script from this folder.
To deploy use deploy.sh
script.
Note that deploying requires configuring two environment variables:
GITHUB_SECRET
should be equal to the Hook Secret which you will use when creating a GitHub Hook at https://github.com/{org}/{repo}/settings/hooksSENDGRID_SECRET
should be equal to SendGrid API secret which you get when you add SendGrid to your Cloud Project (see docs for the initial setup).Firestore needs to contain github-label-subscriptions
collection.
The following Security Rules must be configured to ensure that each user can only edit its own subscriptions
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /github-label-subscriptions/{userId} { allow read, update, delete: if request.auth.uid == userId; allow create: if request.auth.uid != null; } match /{document=**} { allow read, write: if false; } } }
Subscriptions are stored in the Firestore collection called github-label-subscriptions
with each document at github-label-subscriptions/{userId}
path has the following format
message Subscription { string email = 1; // Each subscription has format repo-name:label-name. For example // subscribing to label 'bug' in 'dart-lang/sdk' repo would be // recorded as 'dart-lang/sdk:bug'. repeated string subscriptions = 2; }
Subscriptions are intended to be managed by users themselves so they are indexed by Firebase UID issued by Firebase authentification.
Mails are sent via SendGrid.