Welcome to the events-backend-module-github backend module!
This package is a module for the events-backend backend plugin
and extends the event system with an GithubEventRouter.
The event router will subscribe to the topic github
and route the events to more concrete topics based on the value
of the provided x-github-event metadata field.
Examples:
x-github-event |
topic |
|---|---|
pull_request |
github.pull_request |
push |
github.push |
repository |
github.repository |
Please find all possible webhook event types at the official documentation.
# From your Backstage root directory
yarn --cwd packages/backend add @backstage/plugin-events-backend-module-github
// packages/backend/src/index.ts
backend.add(import('@backstage/plugin-events-backend-module-github'));
// packages/backend/src/plugins/events.ts
const eventRouter = new GithubEventRouter({ events: env.events });
await eventRouter.subscribe();
Add the signature validator for the topic github:
// packages/backend/src/plugins/events.ts
+ import { createGithubSignatureValidator } from '@backstage/plugin-events-backend-module-github';
// [...]
const http = HttpPostIngressEventPublisher.fromConfig({
config: env.config,
events: env.events,
ingresses: {
+ github: {
+ validator: createGithubSignatureValidator(env.config),
+ },
},
logger: env.logger,
});
Webhook authentication is secure by default. Requests to the module's endpoint /api/events/http/github without a configured webhook secret return an HTTP 403 Forbidden status. A secret is configured either as a single shared secret via events.modules.github.webhookSecret, or per GitHub App via the webhookSecret of an entry in integrations.github[].apps.
This only covers the module's own endpoint. Routes created solely through events.http.topics have no validator attached and still accept unauthenticated requests.
Add the following to your app-config.yaml:
events:
modules:
github:
webhookSecret: your-secret-token
For more details on securing webhooks on GitHub, see the GitHub documentation.
For development or testing environments where a webhook secret cannot be configured, you can set dangerouslyAllowUnauthenticatedEvents: true as an explicit escape hatch under the module configuration:
events:
modules:
github:
dangerouslyAllowUnauthenticatedEvents: true
Only use dangerouslyAllowUnauthenticatedEvents: true for development or testing. Never enable this option in production environments.
The module
githubfor the Backstage backend plugin "events-backend" adding an event router and signature validator for GitHub.