Skip to content

Basic app that monitors an entire GitHub Organization for commits, forks and issues, using Github Webhooks. Demo: https://sml-github-monitor.herokuapp.com

License

Notifications You must be signed in to change notification settings

eranshmil/github-monitor

Repository files navigation

Github Monitor

Basic app that monitors an entire GitHub Organization for commits, forks, and issues, using Github Webhooks.
Developed with Express and Angular.

Demo: https://sml-github-monitor.herokuapp.com

Screenshot

Table of contents

Environment variables

The server can read the variables from the .env file located in the root path.
If you don't want to use OS's environment variables, such as in your local machine, just create a copy of the file .env.example into .env.

Development

  1. Clone/fork this project.

  2. Configure environment variables.

  3. Install dependencies:

    yarn install
  4. Start the server/client:

    yarn dev
    
    # server only
    yarn dev:server
    
    # client only
    yarn dev:client
  5. Navigate to http://localhost:4200/.

  • To debug breakpoints outside the scope of the routes, you need to run the script yarn dev:server:brk, that changes the --inspect flag into --inspect-brk.

Debugging with VSCode

In order to debug with VSCode instead of Chrome DevTools, there are two options:

  1. Go to the Debugger section, choose Attach to process and click the play button.
  2. Read about Node: Auto Attach feature in the article Debug Your Node.js App in 60 Seconds by John Papa or in VSCode documentation. Using Auto Attach

Webhook testing

First, we need to install a program that exposes our localhost to the internet. If you already use another program, expose port 3000 and skip to the second step.

  1. Signup to ngrok, download and install.

  2. Expose port 3000:

    ./ngrok http 3000
  3. Copy the url from the second Forwarding line, should look like https://xxxxxxxx.ngrok.io.

  4. Goto Settings/Webhooks in your repository, and fill in the form:

    • Payload URL: https://xxxxxxxx.ngrok.io

    • Content type: application/json

    • Secret: The GITHUB_SECRET defined in your environment, you could generate a random string using:

      node -p "crypto.randomBytes(20).toString('hex')"
    • Let me select individual events: Pushes, Forks, Issues

Production build

  1. Configure environment variables, it's important to set NODE_ENV to production.

  2. Run build script:

    yarn build
    
    # server only
    yarn build:server
    
    # client only
    yarn build:client
  3. The server code will be bundled in dist/server.js and the client in dist/client.

  • If you use Heroku, you can enable automatic deploy and the project will work without any further configuration.
    The postinstall script will create a build for both server and client.
    And the start script will run the server that serves the client in the base url of your deployment.

Endpoints

Path Method Description
/ GET Serving the client (production only)
/webhook POST Receive events from Github
/commit GET List all commits from PushEvent
/fork GET List all forks from ForkEvent
/issue GET List all issues from IssuesEvent

About

Basic app that monitors an entire GitHub Organization for commits, forks and issues, using Github Webhooks. Demo: https://sml-github-monitor.herokuapp.com

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published