How to use the probot.createProbot function in probot

To help you get started, we’ve selected a few probot 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 integrations / slack / test / integration / index.js View on Github external
const { createProbot } = require('probot');
const { GitHubAPI, ProbotOctokit } = require('../../lib/github/client');
const logger = require('../../lib/logger');
const nock = require('nock');

const slackbot = require('../slackbot');
const app = require('../../lib');
const models = require('../../lib/models');

const cache = require('../../lib/cache');

const probot = createProbot({});
const robot = probot.load(app);

// raise errors in tests
robot.catchErrors = false;

// Expect there are no more pending nock requests
beforeEach(async () => nock.cleanAll());
afterEach(() => expect(nock.pendingMocks()).toEqual([]));

// Ensure there is a connection established
beforeAll(async () => {
  if (global.gc) {
    global.gc();
  }
  models.sequelize.authenticate();
});
github integrations / jira / lib / run.js View on Github external
require('dotenv').config()
const throng = require('throng')

if (process.env.NEWRELIC_KEY) {
  require('newrelic') // eslint-disable-line global-require
}

require('../lib/config/sentry').initializeSentry()

const { findPrivateKey } = require('probot/lib/private-key')
const { createProbot } = require('probot')
const app = require('./configure-robot')

const workers = process.env.WEB_CONCURRENCY || 1

const probot = createProbot({
  id: process.env.APP_ID,
  secret: process.env.WEBHOOK_SECRET,
  cert: findPrivateKey(),
  port: process.env.TUNNEL_PORT || process.env.PORT || 3000,
  webhookPath: '/github/events',
  webhookProxy: process.env.WEBHOOK_PROXY_URL
})

/**
 * Start the probot worker.
 */
function start () {
  probot.load(app)
  probot.start()
}
github probot / actions-adapter / index.js View on Github external
module.exports = (...handlers) => {
  // Setup Probot app
  const githubToken = process.env.GITHUB_TOKEN;
  const probot = createProbot({ githubToken });
  probot.setup(handlers);

  // Process the event
  const event = process.env.GITHUB_EVENT_NAME;
  const payloadPath = process.env.GITHUB_EVENT_PATH;
  // eslint-disable-next-line global-require, import/no-dynamic-require
  const payload = require(path.resolve(payloadPath));
  core.debug(`Receiving event ${JSON.stringify(event)}`);
  probot.receive({ name: event, payload, id: uuid.v4() }).catch(err => {
    // setFailed logs the message and sets a failing exit code
    core.setFailed(`Action failed with error: ${err.message}`);
  });
};
github opencollective / opencollective-bot / src / index.ts View on Github external
export function main(port: number): Server {
  /* Credentials */

  if (
    !process.env.APP_ID ||
    !process.env.WEBHOOK_SECRET ||
    !(process.env.PRIVATE_KEY || process.env.PRIVATE_KEY_PATH)
  ) {
    throw new Error('Missing credentials.')
  }

  /* Probot setup */

  const cert = findPrivateKey() as string

  const probot = createProbot({
    id: parseInt(process.env.APP_ID, 10),
    secret: process.env.WEBHOOK_SECRET,
    cert: cert,
    port: port,
  })

  /* Load apps */

  const apps: ApplicationFunction[] = [
    opencollective,
    require('probot/lib/apps/default'),
    require('probot/lib/apps/sentry'),
    require('probot/lib/apps/stats'),
  ]
  ;(process as NodeJS.EventEmitter).on(
    'unhandledRejection',
github kamilkisiela / graphql-inspector / api / webhook.js View on Github external
const loadProbot = appFn => {
  probot =
    probot ||
    createProbot({
      id: process.env.APP_ID,
      secret: process.env.WEBHOOK_SECRET,
      cert: findPrivateKey(),
    });

  if (typeof appFn === 'string') {
    appFn = resolve(appFn);
  }

  probot.load(appFn);

  return probot;
};
github all-contributors / all-contributors-bot / src / utils / getProbot.js View on Github external
function getProbot() {
    const probot = createProbot({
        id: process.env.APP_ID,
        secret: process.env.WEBHOOK_SECRET,
        cert: findPrivateKey(),
    })

    if (process.env.SENTRY_DSN) {
        probot.load(require('probot/lib/apps/sentry'))
    }

    return probot
}
github probot / serverless-lambda / index.js View on Github external
const loadProbot = appFn => {
  probot = probot || createProbot({
    id: process.env.APP_ID,
    secret: process.env.WEBHOOK_SECRET,
    cert: findPrivateKey()
  })

  if (typeof appFn === 'string') {
    appFn = resolve(appFn)
  }

  probot.load(appFn)

  return probot
}
github googleapis / repo-automation-bots / packages / gcf-utils / src / gcf-utils.ts View on Github external
async loadProbot(appFn: ApplicationFunction): Promise {
    if (!this.probot) {
      const cfg = await this.getProbotConfig();
      this.probot = createProbot(cfg);
    }

    this.probot.load(appFn);

    return this.probot;
  }
github tibdex / probot-serverless-now / src / utils.ts View on Github external
const createProbot = () => {
  const options = {
    cert: String(findPrivateKey()),
    id: Number(process.env.APP_ID),
    secret: process.env.WEBHOOK_SECRET,
  };
  return _createProbot(options);
};