This repository is an example of how to deploy the "Hello, World" of probot apps to Google Cloud Functions (GCF).
Use Node.js 22. Install dependencies:
npm install
Start the Probot development server:
npm start
Follow the instructions to register a new GitHub app.
To run the same HTTP handler used in Google Cloud, set your Probot environment variables and run:
npx functions-framework --target=probotAppThe function accepts signed GitHub webhook requests at http://localhost:8080/.
The app is continuously deployed to Google Cloud Functions on Node.js 22 using the auth and setup-gcloud GitHub Actions. Deployments run one at a time to avoid overlapping function updates. The probotApp entry point uses @probot/adapter-google-cloud-functions, which brings in Probot 14 as a peer dependency. See .github/workflows/deploy.yml for the deployment workflow.
As an alternative, terraform/ deploys an HTTP-triggered second-generation function using Node.js 22, dedicated build/runtime service accounts, and Secret Manager credentials. It packages only the required application files, using the function.js entry point from package.json and invoking probotApp. Source changes trigger a new deployment.
Prerequisites:
- Terraform 1.7+, the Google Cloud CLI, and an existing GCP project with billing enabled.
- Credentials allowed to enable APIs, manage service accounts and project/secret IAM, create source buckets, deploy functions, and set Cloud Run IAM. The deployer also needs Service Account User (
iam.serviceAccounts.actAs) on the build and runtime accounts. - An organization policy that permits public invocation (
allUsers). GitHub cannot supply GCP IAM credentials; Probot authenticates deliveries using the webhook signature.
Authenticate and create the two secrets in your project (skip creation if they already exist):
gcloud auth application-default login
export PROJECT_ID="your-gcp-project-id"
gcloud services enable secretmanager.googleapis.com --project="$PROJECT_ID"
gcloud secrets create probot-private-key --project="$PROJECT_ID" \
--replication-policy=automatic --data-file=/path/to/github-app.private-key.pem
# Prompt for the webhook secret without echoing it; use the same value in your GitHub App settings.
printf 'Webhook secret: '; read -rs WEBHOOK_SECRET; echo
printf '%s' "$WEBHOOK_SECRET" | gcloud secrets create probot-webhook-secret \
--project="$PROJECT_ID" --replication-policy=automatic --data-file=-
unset WEBHOOK_SECRETSecret values are never read by Terraform or included in its state. Keep the PEM file outside this repository.
cd terraform
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your project ID and GitHub App ID.
terraform init
terraform plan
terraform apply
terraform output -raw webhook_urlPaste the output URL (including its root / path) into your GitHub App's Webhook URL field. Set Webhook secret to the value stored above, enable Issues events, grant Issues: Read and write, and install the app on a repository. Open an issue to verify that the app comments "Hello, World!".
The template defaults to secret version 1. For existing secrets or rotation, set the corresponding secret version variables and apply again. Local state and variable files are ignored by Git; still protect state with an access-controlled backend when sharing deployments. Commit the generated provider lock file for reproducible installs.
Use Terraform for subsequent updates to this function; the existing deployment workflow is independent and is not modified by this template. Terraform creates billable resources. terraform destroy removes its managed resources but leaves the existing secrets and enabled APIs in place.
To check the template without deploying, run terraform validate and terraform test from terraform/ after initialization. The tests mock Google Cloud resources and do not require GCP credentials.