How to use the probot/lib/private-key.findPrivateKey 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 / jira / test / setup / app.js View on Github external
.post(/\/installations\/[\d\w-]+\/access_tokens/)
    .reply(200, {
      token: 'mocked-token',
      expires_at: '9999-12-31T23:59:59Z'
    })
    .get('/repos/test-repo-owner/test-repo-name/contents/.github/jira.yml')
    .reply(200, {
      content: Buffer.from(`jira: ${process.env.ATLASSIAN_URL}`).toString('base64')
    })

  const configureRobot = require('../../lib/configure-robot')

  global.app = configureRobot(new Application({
    app: createGitHubApp({
      id: 12257,
      cert: findPrivateKey()
    }),
    cache: cacheManager.caching({
      store: 'memory',
      ttl: 60 * 60 // 1 hour
    })
  }))
})
github wilhelmklopp / chaos-monkey / lib / create-chaos.js View on Github external
async function main() {
  const pem = findPrivateKey();
  const jwt = githubApp({ id: process.env.APP_ID, cert: pem })();
  console.log(jwt);
  const github = new GitHubAPI();
  github.authenticate({
    type: 'app',
    token: jwt,
  });
  const { data: installations } = await github.apps.getInstallations({ per_page: 100 });
  // for each installation, create an installation token
  await Promise.all(installations.map(async (installation) => {
    const { data: token } = await github.apps.createInstallationToken({
      installation_id: installation.id,
    });
    const installationGitHub = new GitHubAPI();
    installationGitHub.authenticate({ type: 'token', token: token.token });
    const { data } = await installationGitHub.apps.getInstallationRepositories({
github integrations / slack / lib / run.js View on Github external
#!/usr/bin/env node

require('dotenv').config();

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

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

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

probot.load(app);

probot.start();
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'),
  ]
github integrations / jira / lib / run.js View on Github external
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()
}

throng({
  workers,
  lifetime: Infinity
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 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 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);
};