aboutsummaryrefslogtreecommitdiff

gohook

Small program written in Golang to automatically pull repositories when a webhook is received.

How it works

Nearly the entire application is controlled by ~/.gohook.yaml, if the file does not exist the application will look for a "gohook.yaml" in the current directory

~/.gohook.yaml

# Address and port the Go "net/http" server will listen on
listen: 0.0.0.0:10000
# Map of URLs to look for in the hook, with options
repos:
   https://gogs.example.com/bob/site:
      dir: /var/www/example.com/jekyll
      branch: master
      location: origin
   https://gogs.example.com/bob/app:
      dir: /var/www/app.example.com
      # Branch is optional
      # Location is also optional
   https://gogs.example.com/bob/provided-app:
      # Gohook will iterate through the array and update each
      # and every repository
      dirs:
        - /usr/jails/stuff.example.com/var/www/app
        - /usr/jails/things.example.com/var/www/app
        - /usr/jails/widget-seller.example.com/var/www/app
      # Noe that branch is set for all of the locations
      branch: production
      location: origin

It's designed to be extremely siplistic way for you to have your production ( or Development ) server automatically update git repositories when you push to your Git server.

Installation

$ go get git.riedstra.us/mitch/gohook
$ cd $GOPATH/src/git.riedstra.us/mitch/gohook
$ go build
$ $EDITOR $HOME/.gohook.yaml

Nginx can be used to proxy this application into your domain so you don't have to open any part of your firewall if you don't want to.

Configure your git server ( e.g. Gogs, Github, Gitlab? ) to send the HTTP POST request to the URL and it'll do it's magic.