Make probot usable with RunKit
See original GitHub issueFeature Request - probot in RunKit
Users want to use probot with RunKit instead of self-hosted NodeJS or platforms like Glitch
Background
RunKit notebooks are interactive javascript playgrounds connected to a complete node environment right in your browser. Every npm module pre-installed. RunKit can host any notebook as an endpoint if required.
Solution
Add a method for starting probot from within a RunKit Notebook (start probot from inside JavaScript code, instead of from the command line)
This might already be possible by using the .createProbot
method or the .start
, although I doubt it by inspecting the structure of the probot object/class.
I would propose a .createEndpoint
method for probot. That method would create an importable endpoint for either NodeJS itself or even framework like express. The following code shows the proposed method in action.
A: (using pure NodeJS)
var probot = require("probot");
exports.endpoint = probot.createEndpoint(app => {
// your `probot` code here
}, options)
B: (using ExpressJS)
var probot = require("probot");
var express = require("@runkit/runkit/express-endpoint/1.0.0");
var app = express(exports);
app.use(probot.createEndpoint(app => {
// your `probot` code here
}, options));
The first argument would be the standard app
function that is passed to the export for probot.
The second argument would be an options
object containing the same options that the probot-run script can take.
The introduced method should ideally return an object with the same signature as the callback passed to server.listen
in NodeJS directly. The only change here is removing the explicit server creation and port binding.
Teachability, Documentation, Adoption, Migration Strategy The change should not be too complex for someone very versed with the project. No migration required as only functionality is added.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:20 (11 by maintainers)
Top GitHub Comments
I did a quick test to see if this works correctly now; using @tcbyrd’s code example but with a newer version of Probot, I was able to see errors in actual Probot code:
This is great - it means that now Probot code is being run, it tries to start up but is missing environment variables. One could set those (e.g.
process.env.APP_ID = 123
) before runningProbot.run
.I’ll close this out 🎉
@jannik-mohemian 👋 this is indeed very similar to https://github.com/probot/friction/issues/8 - by grabbing the code used in
probot run
, you can start it with a programmatic API. We’d still like to have this kind of setup as a first-class API, but in the meantime this might help get you started:Let me know if that helps! I’m not sure how you can get a Webhook URL for GitHub to send webhooks to your Runkit app so that might be a challenge - very curious to hear what you do!