now.sh extension for Probot
A Probot extension to make it easier to run your Probot Apps serverless on now.sh v2.
This extension is based on
@probot/serverless-lambda and uses much of its code.
$ npm install @sanalytics/probot-serverless-now
// index.js;;// the following is different from serverless-lambda, as the current working directory does not contain the package.json on now.sh v2;// make sure to pass appName and appVersion;
This package moves the functionality of
probot run into a handler suitable for usage on now.sh v2. Follow the documentation on Environment Configuration to setup your app's environment variables. You can add these to
.env, but for security reasons you may want to use the now CLI to set Environment Variables for the function so you don't have to include any secrets in the deployed package.
Since you might run into issues with limits related to now.sh environment variables and secrets, just use the pem keyfile (or create one using the key included in your
.env file where all
\n are replaced with actual new lines) together with
now secret add private_key "$(cat key.pem | base64)"
Then set the environment variable
PRIVATE_KEY either in your
now.json as shown below or in your deploy command with
now -e PRIVATE_KEY="@private_key@
To decode the private key during your app startup, use node's
Buffer.from before you initalize your app:
processenvPRIVATE_KEY = Buffer;
Since now.sh functions do not start a normal node process, the best way we've found to test this out locally is to use
zeit/micro. Having a
dev script in your
package.json allows you to continue working from
https://localhost:3000/probot before deploying your function to now.sh. When you're developing with typescript, make sure to run
npm i -D typescript ts-node micro-dev @types/node @types/micro and
npm i micro probot
Long running tasks
Some Probot Apps that depend on long running processes or intervals might not work with this extension or result in high costs. This is due to the inherent architecture of serverless functions, which are designed to respond to events and stop running as quickly as possible. For longer running apps we recommend using other deployment options.
Only responds to Webhooks from GitHub
This extension is designed primarily for receiving webhooks from GitHub and responding back as a GitHub App. If you are using HTTP Routes in your app to serve additional pages, you should take a look at
serverless-http, which can be used with Probot's express server by wrapping