This event source creates a webhook to listen for incoming Github Events.
The GitHub source is provided by the Knative project and needs to be installed separately on Kubernetes. This also means it is not currently available in
apiVersion: sources.knative.dev/v1alpha1 kind: GitHubSource metadata: name: githubsource-sample spec: eventTypes: - pull_request ownerAndRepository: "<your GitHub org>/<your GitHub repo>" accessToken: secretKeyRef: name: githubsecret key: accessToken secretToken: secretKeyRef: name: githubsecret key: secretToken sink: ref: apiVersion: eventing.triggermesh.io/v1alpha1 kind: RedisBroker name: triggermesh
The Github event source emits events that begin with
dev.knative.source.github. and end in the event type. For example:
- GitHub Tokens
Create GitHub Tokens
Create a personal access token for GitHub that the GitHub source can use to register webhooks with the GitHub API. Also decide on a secret token that your code will use to authenticate the incoming webhooks from GitHub (secretToken).
The token can be named anything you find convenient. The Source requires
admin:repo_hook, to let it fire events from your public repositories and to create webhooks for those repositories. Copy and save this token; GitHub will force you to generate it again if misplaced.
Here's an example for a token named "GitHubSource Sample" with the recommended scopes:
Verify the GitHub webhook was created by looking at the list of webhooks under the Settings tab in your GitHub repository. A hook should be listed that points to your Knative cluster with a green check mark to the left of the hook URL, as shown below.
More information on the Github Event Source can be found here: https://knative.dev/docs/eventing/samples/github-source/