Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.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
})
}))
})
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({
#!/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();
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'),
]
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
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
}
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;
};
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
}
const createProbot = () => {
const options = {
cert: String(findPrivateKey()),
id: Number(process.env.APP_ID),
secret: process.env.WEBHOOK_SECRET,
};
return _createProbot(options);
};