A Node.js server for GitHub app to assist external contributors and save maintainers' time
- When an external contributor (not the internal team) raises a PR, post a comment to sign CLA and label PR
Pending CLA - On signing CLA, remove
Pending CLAlabel from all the PRs of that user. Never ask that user to sign the CLA on any of our repo in future - On
rudder-transformerPR merge, post a comment to raise PR inintegrations-config - On
integrations-configPR merge, post a comment to join Slack's product-releases channel to get notified when that integration goes live - On
integrations-configPR merge, post a comment to raise PR inrudder-docs - List of open PRs by external contributors
- Notify on Slack when
product reviewlabel is added to a PR - Analyze merged PRs and suggest next actions
- Analyze docs pages using AI on PR labelled with
docs review
The Next Actions feature automatically analyzes merged pull requests from external contributors and suggests next actions based on the code changes. Here's how it works:
- Triggers: Listens to
pull_request.closedevents and checks if the PR was merged - Analysis: Extracts production code changes (excludes test files)
- External API: Sends changes to services such as DocsAgent
- Comments: Posts the API response as a comment on the PR
- Node.js 20 or higher
- A GitHub App subscribed to Pull Request events and with the following permissions:
- Pull requests: Read & write
- Metadata: Read-only
- Your GitHub App Webhook must be configured to receive events at a URL that is accessible from the internet.
- (Only for local development) A tunnel to expose your local server to the internet (e.g. smee, ngrok or cloudflared)
- Clone this repository.
- Create a
.envfile similar to.env.exampleand set actual values. If you are using GitHub Enterprise Server, also include aENTERPRISE_HOSTNAMEvariable and set the value to the name of your GitHub Enterprise Server instance. - Install dependencies with
npm install. - Start the server with
npm run server. - Ensure your server is reachable from the internet. This is necessary for GitHub to send webhook events to your local server.
- If you're using
smee, runsmee -u <smee_url> -t http://localhost:3000/api/webhook.
- If you're using
- Ensure your GitHub App includes at least one repository on its installations.
- Register a GitHub app for your GitHub organization. Make sure to activate the webhook with webhook url
https://YOUR_WEBSITE/api/webhookin your app with a secret. Enable Permissions & Events as you may need, at minimum pull_request and issue related events should be enabled. - Install your GitHub app in all the repos where you need this app.
- Clone this repo OR download the
build/docker-compose.ymlto install via dockerhub image - Update the
docker-compose.ymlfile with the environment variables obtained from step 2. Make sure to replace placeholder values with your actual GitHub App details. - To convert GitHub App's private key to base64, use this command:
openssl base64 -in /path/to/original-private-key.pem -out ./base64EncodedKey.txt -A - Run
docker-compose buildto build the service - Run
docker-compose upto create and start the container - Test by visiting
http://localhost:3000OR whateverWEBSITE_ADDRESSenvironment variable you've configured
To set up the Docs Agent feature:
- Locate your Docs Agent API project. This is a separate service that analyzes documentation and provides suggestions.
- In the Docs Agent API project's environment configuration, add the following URL to the
ALLOWED_WEBHOOK_URLSvariable:Replacehttps://your-github-app-host.com/api/commentyour-github-app-host.comwith the actual hostname where your GitHub App is deployed.
This setup allows the Docs Agent to send webhook requests to your GitHub App.
With your server running, you can now create a pull request on any repository that
your app can access. GitHub will emit a pull_request.opened event and will deliver
the corresponding Webhook payload to your server.
The server in this example listens for pull_request.opened events and acts on
them by creating a comment on the pull request, with the message in message.md,
using the octokit.js rest methods.
To keep things simple, this example reads the GITHUB_APP_PRIVATE_KEY from the
environment. A more secure and recommended approach is to use a secrets management system
like Vault, or one offered
by major cloud providers:
Azure Key Vault,
AWS Secrets Manager,
Google Secret Manager,
etc.