A GitHub App built with Probot that allows Pull Request authors to self-approve their Pull Requests.
Special thanks to dkhmelenko/autoapproval for providing some inspiration and also some code implementation for this App.
For some repositories, the Pull Request have to be approved before it can be merged.
This GitHub App allows some whitelisted repository maintainers to self-approve their Pull Requests, so they can directly approve and merge their own Pull Requests.
Install dependencies
npm install
Build the project
npm run build
Start the server
npm start
Follow the instructions to register a new GitHub app.
Configure the app in the .env
file by following the following instructions
- Copy the
.env.example
file to.env
- Fill in the following values according to the following descriptions:
APP_ID
: the ID of the app, which you can get from the app settings page.GITHUB_CLIENT_ID
: the Client ID of the app, which you can get from the app settings page.GITHUB_CLIENT_SECRET
: the Client Secret of the app, which you can generate and get from the app settings page.WEBHOOK_SECRET
: the Webhook Secret that you generated when you created the app.PRIVATE_KEY
: the contents of the private key you downloaded after creating the app.
- [OPTIONAL] Change the
PORT
to the port you want the app to listen to. - [OPTIONAL] Setup HTTPS and domain name for the app. You can use multiple ways to do this (e.g. Nginx & Certbot).
- Set the Webhook URL of your GitHub App in the app settings page to the
WEBHOOK_URL
you configured in the.env
file.
If you want to update the app that is deployed on your server, you can follow the following steps:
- Stop the server
- Pull the latest changes from the repository
- Rerun the npm commands shown above
This app can be continuously deployed to Vercel using the Vercel GitHub app.
- You have two options to begin with:
- Click the following link to deploy this app to Vercel: Deploy with Vercel
- Fork this repository and deploy it manually to Vercel following the Vercel documentation.
- Fill the following environment variables according to the following descriptions:
APP_ID
: the ID of the app, which you can get from the app settings page.GITHUB_CLIENT_ID
: the Client ID of the app, which you can get from the app settings page.GITHUB_CLIENT_SECRET
: the Client Secret of the app, which you can generate and get from the app settings page.WEBHOOK_SECRET
: the Webhook Secret that you generated when you created the app.PRIVATE_KEY
: the contents of the private key you downloaded after creating the app.
- [OPTIONAL] Set the URL of your Vercel app if you want to use a custom domain.
- Set the Webhook URL of your GitHub App in the app settings page to
https://<your-vercel-app-url>/api/github/webhooks
.
If you want to update the app that is deployed on Vercel, you can follow the following steps:
- If you used the above link to deploy the app
- Go to the Vercel dashboard and select the app you deployed
- Click on the
Git Repository
button to go the the GitHub repository - Delete the repository
- Redeploy the app using the above guide
- If you forked the repository and deployed it manually
- Go to the Vercel dashboard and select the app you deployed
- Click on the
Git Repository
button to go the the GitHub repository - Sync from the upstream repository
- Wait for the Vercel to automatically redeploy the app
- Vercel expects to find your lambda functions under
/api
folder. Make sure your functions are placed there and double check Vercel detected your Lambda Functions during the deployment process by checking the logs:
The api/github/webhooks/index.ts file is handling requests to POST /api/github/webhooks
, so make sure to configure your GitHub App registration's webhook URL accordingly.
In order to use the bot, the config file should be provided. Config file should be defined in your repository. Config file is the yml file with the path .github/self-approval-pull-request.yml
. And the file should have these 3 entries: self_approval_comments
, from_author
and apply_labels
.
Define the list of comments that will be considered as self-approval.
self_approval_messages:
- "I self-approve!"
- "I self-certify!"
Define the list of GitHub users who can self-approve their Pull Request.
from_author:
- "Cubik65536"
- "<GitHub ID of other project maintainer>"
Assign an empty array if you want everyone can self-approve their Pull Requests (example: from_author: []
).
Defines the list of labels on PR, which should be added once PR was approved. For example:
apply_labels:
- "can-be-merged"
- "self-approved"
Assign an empty array if no labels should be applied to PRs (example: apply_labels: []
).
ISC © 2022-2024 iXOR Technology & Cubik65536