How to use @octokit/webhooks - 4 common examples

To help you get started, we’ve selected a few @octokit/webhooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github probot / probot / src / index.ts View on Github external
constructor (options: Options) {
    options.webhookPath = options.webhookPath || '/'
    options.secret = options.secret || 'development'
    this.options = options
    this.logger = logger
    this.apps = []
    this.webhook = new Webhooks({
      path: options.webhookPath,
      secret: options.secret
    })
    this.githubToken = options.githubToken
    this.Octokit = options.Octokit || ProbotOctokit
    if (this.options.id) {
      if (process.env.GHE_HOST && /^https?:\/\//.test(process.env.GHE_HOST)) {
        throw new Error('Your \`GHE_HOST\` environment variable should not begin with https:// or http://')
      }

      this.app = new OctokitApp({
        baseUrl: process.env.GHE_HOST && `https://${process.env.GHE_HOST}/api/v3`,
        id: options.id as number,
        privateKey: options.cert as string
      })
    }
github curioswitch / curiostack / tools / cloudbuild-github / src / webhook.ts View on Github external
export default async function handleWebhook(
  req: CloudFunctionsRequest,
  res: Response,
) {
  const secret = await keyManager.getWebhookSecret();

  const webhooks = new WebhooksApi({
    secret,
  });

  if (!webhooks.verify(req.rawBody.toString(), req.get('X-Hub-Signature'))) {
    console.error('Invalid signature.');
    res.status(HttpStatus.BAD_REQUEST).end();
    return;
  }

  const event = req.body;
  const eventType = req.get('X-GitHub-Event');
  switch (eventType) {
    case 'pull_request':
      await handlePullRequest(event as PullRequest);
      break;
    default:
github curioswitch / curiostack / tools / cloudbuild-github / src / webhook.js View on Github external
export async function handleWebhook(req: any, res: any) {
  if (
    !verify(
      await keyManager.getWebhookSecret(),
      req.rawBody.toString(),
      req.get('X-Hub-Signature'),
    )
  ) {
    console.error('Invalid signature.');
    res.status(400).end();
    return;
  }

  const event = req.body;
  const eventType = req.get('X-GitHub-Event');
  switch (eventType) {
    case 'pull_request':
      await handlePullRequest(event);
      break;
github smooth-code / bundle-analyzer / apps / server / src / api / webhooks.js View on Github external
import WebhooksApi from '@octokit/webhooks'
import { handleGitHubEvents } from 'modules/github'

const webhooks = new WebhooksApi({
  secret: process.env.GITHUB_WEBHOOK_SECRET,
  path: '/event-handler',
})

webhooks.on('*', handleGitHubEvents)

export default webhooks.middleware

@octokit/webhooks

GitHub webhook events toolset for Node.js

MIT
Latest version published 4 months ago

Package Health Score

86 / 100
Full package analysis

Popular @octokit/webhooks functions

Similar packages