Deploying Probot Apps on Now v2 🤖

February 28, 2019

Deploying Probot Apps on Now v2

TLDR; Use this package and convert your private key to base64

What will be covered?

Zeit Now is a low cost and easy to use deployment platform. Their serverless infrastructure is a great fit for Probot, a framework for building GitHub Apps that automate and improve your workflow. So what’s the problem? With the release of Now’s v2 platform, the preferred method of deployment is to expose an HTTP request handler rather than run your own server instance (Express, Koa, etc). Unfortunately, Probot does not directly expose a request handler for your app. This guide will cover how we can work around this in order to deploy our Probot Apps on Now v2.

  • Wrap Probot App in Serverless Extension
  • Set Secrets in Now
  • Deploy to Now

What won’t be covered?

It is expected that you have already generated a Probot App, configured the appropriate setting in GitHub, and have the app id, webhook secret, and private key associated with the GitHub App. If not, follow the Probot documentation, and come back when you’ve got everything you need.

Wrap Probot App in Serverless Extension

As mentioned above, Now expects a request handler for your app. Rather than initializing everything manually, and digging into the Probot source, we are going to make use of a helper package.

Start by installing the @chadfawcett/probot-serverless-now package:

npm install @chadfawcett/probot-serverless-now

Next, we will create the Now v2 entrypoint file, named now.js, that wraps our app and exposes the expected request handler. Here, ./app is our Probot application file.

Set Secrets in Now

We don’t want any of our secrets being committed into source control or exposed in any way through the deployment. To solve this, Now allows for setting secrets on your account. The app id and webhook are pretty straightforward to add. Run the following in your terminal, being sure to provide the values for your app:

now secret add app-id <your-github-app-id>
now secret add webhook-secret <your-webhook-secret>

The private key isn’t as easy since Now doesn’t support multiline environment variables. Fortunately though, Probot accepts a base 64 encoded version of the key. We can output the contents of the certificate file and pipe it to the base64 command before adding to Now.

now secret add private-key-base64-encoded $(cat /path/to/private-key.pem | base64)

Deploy to Now

With our request handler and secrets set, the configuration file for Now is next. The config is a file named now.json, with the following values:

  1. We need to specify the platform version we want to use. In this case v2.
  "version": 2
  1. The environment variables need to be pointed to the secrets set in the previous step (The @ indicates the value is stored in a secret).
"env": {
"APP_ID": "@app-id",
"WEBHOOK_SECRET": "@webhook-secret",
"PRIVATE_KEY": "@private-key-base64-encoded"
  1. The whole reason for wanting a request handler for our app was so we could take advantage of the @now/node builder. Here is where we tell Now to use our entrypoint file created earlier.
"builds": [{ "src": "now.js", "use": "@now/node" }]
  1. Lastly, we specify that we want our app accessible from the root path of the URL. (Feel free to adjust as necessary)
"routes": [{ "src": "/", "dest": "/now.js" }]

Here is what the final config should look like:

🚀 Deploy by running the following command in your terminal.

now deploy

When Now has finished deploying, it will provide the URL to access your app! By default, the project’s directory name will be used to generate the URL (ie

🤖 Happy Probot-ing!

Are you building an application that integrates with GitHub? We consult on modern web technologies with organizations in all different industries. If you’re looking for a capable team of JavaScript folks, let’s have a chat!

Thanks to Kaileen McCulloch, Jason Etcovitch, and Chris Foster for reviewing this post!

© 2020 Two Story Robot