Code Monkey home page Code Monkey logo

app's Introduction

Self Approval App

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.

Introduction

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.

Local Setup / Server Deployment

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

Configuration

  1. Copy the .env.example file to .env
  2. 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.
  3. [OPTIONAL] Change the PORT to the port you want the app to listen to.
  4. [OPTIONAL] Setup HTTPS and domain name for the app. You can use multiple ways to do this (e.g. Nginx & Certbot).
  5. Set the Webhook URL of your GitHub App in the app settings page to the WEBHOOK_URL you configured in the .env file.

Update the app

If you want to update the app that is deployed on your server, you can follow the following steps:

  1. Stop the server
  2. Pull the latest changes from the repository
  3. Rerun the npm commands shown above

Deploy to Vercel

This app can be continuously deployed to Vercel using the Vercel GitHub app.

Deploying

  1. You have two options to begin with:
  2. 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.
  3. [OPTIONAL] Set the URL of your Vercel app if you want to use a custom domain.
  4. Set the Webhook URL of your GitHub App in the app settings page to https://<your-vercel-app-url>/api/github/webhooks.

Update the app

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
    1. Go to the Vercel dashboard and select the app you deployed
    2. Click on the Git Repository button to go the the GitHub repository
    3. Delete the repository
    4. Redeploy the app using the above guide
  • If you forked the repository and deployed it manually
    1. Go to the Vercel dashboard and select the app you deployed
    2. Click on the Git Repository button to go the the GitHub repository
    3. Sync from the upstream repository
    4. Wait for the Vercel to automatically redeploy the app

Considerations

  • 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:

image

How it works

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.

Configure GitHub Repository

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.

self_approval_comments

Define the list of comments that will be considered as self-approval.

self_approval_messages:
  - "I self-approve!"
  - "I self-certify!"

from_author

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: []).

apply_labels

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: []).

License

ISC © 2022-2024 iXOR Technology & Cubik65536

app's People

Contributors

cubik65536 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Forkers

zxcs001 ixortech

app's Issues

Add Tests

Tests are needed so we can be more confident about the implementation.

[Feature Request]: Add ability of deploying to Vercel

Please choose if applies:

  • I'm currently working on adding this feature.

Describe the solution you'd like

User should be able to deploy this bot using Vercel if they want to.

Describe alternatives you've considered

No response

Anything else?

No response

Please accept these terms

[Feature Request]: Add identification of if the message is for the bot

Please choose if applies:

  • I'm currently working on adding this feature.

Describe the solution you'd like

PR message should begin with @self-approval or @self-approval[bot] for the bot to really react to it so the bot will only react to the message if it's explicitly for it.

Describe alternatives you've considered

No response

Anything else?

https://github.com/all-contributors/app/blob/master/lib/is-message-for-app.js may help when implementing this feature

Please accept these terms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.