Skip to content

Instantly share code, notes, and snippets.

@NipunaMarcus
Created February 22, 2021 09:13
Show Gist options
  • Save NipunaMarcus/8bed56a1409282110474152388cb27c2 to your computer and use it in GitHub Desktop.
Save NipunaMarcus/8bed56a1409282110474152388cb27c2 to your computer and use it in GitHub Desktop.
GitHub trigger
import ballerina/config;
import ballerina/http;
import ballerina/oauth2;
import ballerina/websub;
import ballerinax/github.webhook as webhook;
oauth2:OutboundOAuth2Provider githubOAuth2Provider = new ({
accessToken: config:getAsString("ACCESS_TOKEN_8E422A19_433C_11EB_8E5C_72315290F677")
});
http:BearerAuthHandler githubOAuth2Handler = new (githubOAuth2Provider);
listener webhook:Listener githubWebhookListener = new (8090);
@websub:SubscriberServiceConfig {
subscribeOnStartUp: true,
target: [webhook:HUB, "https://github.com/NipunaMarcus/ballerina/events/*.json"],
hubClientConfig: {
auth: {
authHandler: githubOAuth2Handler
}
},
callback: config:getAsString("CHOREO_APP_INVOCATION_URL")
}
service websub:SubscriberService / on githubWebhookListener {
remote function onIssuesAssigned(websub:Notification notification, webhook:IssuesEvent event) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment