Last active
December 26, 2018 12:36
-
-
Save tcbyrd/1297bbf8fd59ae8a83bf9fb7496422f7 to your computer and use it in GitHub Desktop.
Probot on Now.sh v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": 2, | |
"builds": [ | |
{ "src": "probot.js", "use": "@now/node" } | |
], | |
"env": { | |
"GITHUB_TOKEN": "@github-token", | |
"APP_ID": "@app-id", | |
"PRIVATE_KEY": "@private-key-base64" | |
}, | |
"routes": [ | |
{ "src": "/probot/.*", "dest": "probot.js" } | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createProbot } = require('probot') | |
const loadProbot = appFn => { | |
const probot = createProbot({ | |
id: process.env.APP_ID, | |
cert: Buffer.from(process.env.PRIVATE_KEY, 'base64') | |
}) | |
probot.load(appFn) | |
return probot | |
} | |
const appFn = (app) => { | |
const router = app.route('/probot') | |
router.get('/test', (req, res) => { | |
res.send('hi from probot!!!') | |
}) | |
} | |
module.exports = (req, res) => { | |
const probot = loadProbot(appFn) | |
return probot.server(req, res) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, I had to explicitly add:
const probot = createProbot({ id: process.env.APP_ID, + secret: process.env.GITHUB_TOKEN, cert: Buffer.from(process.env.PRIVATE_KEY, 'base64') })