A Probot extension to make it easier to run your Probot Apps in Google Cloud Functions.
$ npm install @probot/adapter-google-cloud-functions// handler.js
import { createCloudFunction, createProbot } from '@probot/adapter-google-cloud-functions'
import appFn from './index.js'
export const probot = createCloudFunction(appFn, {
probot: createProbot()
})App loading starts when createCloudFunction() is called and occurs once per handler. If loading fails, requests receive HTTP 500 until a new handler is created. All of Probot's exports are re-exported from this package, matching the AWS Lambda and Azure Functions adapters.
This package is ESM-only and requires Probot 14 and Node.js ^20.18.0 || >= 22.0.0. CommonJS handlers can still load it with require() on Node.js versions that support require(esm).
The serverless() export has been removed. Replace it with createCloudFunction() and pass a Probot instance explicitly:
// v1: handler.js (CommonJS)
const { serverless } = require('@probot/adapter-google-cloud-functions')
const appFn = require('./index.js')
module.exports.probot = serverless(appFn)// v3: handler.js (ESM)
import { createCloudFunction, createProbot } from '@probot/adapter-google-cloud-functions'
import appFn from './index.js'
export const probot = createCloudFunction(appFn, { probot: createProbot() })If you passed a module path string to serverless(), import the app function first as shown above. The new handler loads the app once when it is created and does not retry if loading fails. Migrating from v1 also requires upgrading to the Probot and Node.js versions listed above and using ESM or a Node.js version that supports require(esm). For the ESM example, set "type": "module" in your package or use a .mjs handler, and adjust the app import to match its module format and filename.
This package moves the functionality of probot run into a handler suitable for usage on Google Cloud Functions. 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 gcloud cli or Serverless Framework to set Environment Variables for the function so you don't have to include any secrets in the deployed package.
Set WEBHOOK_SECRET to the webhook secret configured for your GitHub App. Deliveries are verified using the x-hub-signature-256 header and Google Cloud Functions' request.rawBody buffer before being dispatched to your app. Local emulators must also provide the original request bytes in request.rawBody; a parsed or reserialized JSON body is not sufficient for signature verification.
Configuration is read by Probot's createProbot() using its standard environment configuration, without adapter-specific overrides.
The handler returns:
- HTTP 200 with
{ "ok": true }after successful processing. - HTTP 400 with
{ "error": "Missing required headers: ..." }whenX-GitHub-Delivery,X-GitHub-Event, orX-Hub-Signature-256is missing. - HTTP 400 with
{ "error": "Webhook processing failed" }for invalid signatures or invalid JSON. - HTTP 500 with
{ "error": "Webhook processing failed" }for app loading or app handler errors. Error details are logged server-side rather than returned to the caller.
Use Google's Functions Framework for Node.js to run the HTTP function locally. With the handler example above saved as handler.js, run:
npm install --save-dev @google-cloud/functions-framework
npx functions-framework --source=handler.js --target=probot --port=8080Provide your Probot environment configuration, then send signed webhook POST requests to http://localhost:8080/. The Functions Framework supplies request.rawBody for signature verification. This adapter does not serve a homepage at /probot; requests without the required webhook headers receive HTTP 400.
Some Probot Apps that depend on long running processes or intervals will not work with this extension. 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.
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 probot.server.