https://github.com/brianonn/github-webhook

run github webhooks

https://github.com/brianonn/github-webhook

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

run github webhooks

Basic Info
  • Host: GitHub
  • Owner: brianonn
  • License: mit
  • Language: Go
  • Default Branch: master
  • Size: 9.77 KB
Statistics
  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 8 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.md

Github webhook listener to run a script

First commit.

This small golang app listens on port 5000 for calls to /webhook and checks for pushes to a branch. When it sees a push to a specific branch, it will start a shell script. The branch is currently hardcoded to staging, the script is hardcoded to push.sh. It is intended that the script will contain the commands needed to get the current release and push that to your webserver(s) and restart the servers. For example, the script can pull the current branch and run rsync to send it to remote servers, or launch something on AWS, or build a docker container and push that to a repo, and/or ssh to the remote server to start up a web app, etc.

The github-webapp application will read an environment variable GITHUB_WEBHOOK_SECRET for a secret string, used to prevent random internet user from causing the webhook to run. The same string should also be set in the webhook secret field on the webhook page in Github.

The app uses a single semaphore to limit the number of simultaneously running external scripts to one. So multiple pushes to the same branch within a short time will cause all but the first one to wait for access to the semaphore. Once the external script completes and the semaphore is released, it will allow the next one to run. It is not deterministic which one of multiple waiting pushes will succeed, and there is no guaranteed ordering.

TODO

  • pass port and branch arguments to the script from the command line
  • config file for mapping events on repos to scripts and args
  • option to whitelist github servers to be the only ones that can originate a webhook.
  • option to restrict specific git users only (maybe part of the config file too)
  • use the form <repo>.<event>.<branch>.sh for finding the script to run. This will allow the same instance of github-webhook to serve different repos and different events
  • use an in-order waiting queue, not a semaphore, so that pushes are held and executed in order, rather than randomly
  • use cobra for command line arguments
  • use viper for a proper config file
  • or something else

Owner

  • Name: Brian Onn
  • Login: brianonn
  • Kind: user
  • Location: Vancouver, Canada

GitHub Events

Total
Last Year

Dependencies

Dockerfile docker
  • golang 1.9 build
Godeps/Godeps.json go
  • github.com/google/go-github/github d2b80df1e3eeccae96eb1cb489e65372cc9550c8
  • github.com/google/go-querystring/query 53e6ce116135b80d037921a7fdd5138cf32d7a8a