Coder Social home page Coder Social logo

github-bot's Introduction

hasura-bot ๐Ÿค–

Hasura's own GitHub bot, currently tasked with commenting on pull requests when they are opened/closed/merged.
Deployed on Zeit Now: https://hasura-github-bot.now.sh

Local Setup

  • Fork this repo and clone it on your system:
    git clone https://github.com/<username>/github-bot
  • Navigate into the repo and install the dependencies:
    cd github-bot
    npm install
  • Create a .env file and set GITHUB_TOKEN and WEBHOOK_SECRET env variables.
  • Start a local server using vercel:
    npm run dev
    Note: By default vercel starts the server on port 3000. You can set a different port using the --listen flag.
    npm run dev -- --listen <port>
  • Set up port forwarding with ngrok(install ngrok from here if you don't already have it):
    ngrok http <port>
    In the webhook settings on Github, set the "Payload URL" to the one provided by ngrok.
    Note: Also make sure that the "Content type" field in the webhook settings is set to application/json.

Contribution guidelines

  • Create a new branch:
    git checkout -b <branch-name>
  • Make the required changes in the code.
  • Stage and commit your changes:
    git add .
    git commit -m "<commit message>"
  • Push the changes to your fork:
    git push -u origin <branch-name>
  • Create a pull request to this repo.

github-bot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-bot's Issues

add linter

We should add a linter (probably eslint) and CI to run on every pull request to avoid errors like 087e86e

add null check for pull request body

When one of the pull requests got opened, then our github bot failed to request for a shadow PR recently. After inspecting the particular event, we discovered two things that we should be fixing here:

  1. This case happened because the pull request was opened with an empty description. This leads GitHub to send a null body in the JSON webhook payload. But we seem to miss a null check here and it fails with the following error:
received pull request event: 86444960-0101-11ec-87d3-da8bfea710bd
Error occured in "pull_request handler: TypeError: Cannot read property 'startsWith' of null
    at /var/task/pull_request.js:38:17
    at /var/task/node_modules/@octokit/webhooks/event-handler/receive.js:45:14
    at async Promise.all (index 0)"
2021-08-19T16:46:49.418Z	cff2e006-2b76-46cc-918a-1fbedd9d0ed9	ERROR	ERROR:  Error: Webhook handler error
    at /var/task/node_modules/@octokit/webhooks/event-handler/receive.js:58:19 {
  errors: [
    TypeError: Cannot read property 'startsWith' of null
        at /var/task/pull_request.js:38:17
        at /var/task/node_modules/@octokit/webhooks/event-handler/receive.js:45:14
        at async Promise.all (index 0) {
      event: [Object]
    }
  ]
}
  1. We also noticed another deprecation notice which we could also be fixed here
2021-08-19T17:19:35.405Z	b635adfc-b4eb-46b5-b835-5141b19a08ec	WARN	Deprecation: [@octokit/request-error] `error.code` is deprecated, use `error.status`.
    at RequestError.code (/var/task/node_modules/@octokit/request-error/dist-node/index.js:29:17)
    at /var/task/pull_request.js:56:13
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Promise.all (index 0)

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.