Code Monkey home page Code Monkey logo

harpoon's Introduction

Harpoon

Go Report Card Build Status

Harpoon is a simple Go program that listens for GitHub hooks like push on specific git repository refs and execute a defined command when it occurs.

It can be configured in a TOML configuration file.

That's nothing fancy, just didn't want to install the whole nodejs + npm or Apache + PHP just for this.

Install

go get github.com/agrison/harpoon
go build

Add it to your path if you want.

Runnning

Configuration

You must have a config.toml file located in your directory.

This is a sample TOML file:

port = 9001
addr = "0.0.0.0"
# tunneling stuff
tunnel = true
tunnelName = "foobarbazz"

[events."push:foo/bar:refs/heads/develop"]
cmd = "echo"
args = "Push!"

[events."watch:foo/bar:refs/heads/develop"]
cmd = "echo"
args = "Watch!"

As you can see events and refs can be configured in the events TOML table section.

These keys have the following format events.{event}:{repository}:{ref} where {event} refers to a GitHub WebHook event like push, watch, pull_request, ...; {repository} is the GitHub repository name and {ref} refers to a ref in your git repository like refs/heads/master or refs/tags/v0.0.1.

For the above example, it will echo Push! when something has been pushed to the develop branch of your GitHub repository. It will also echo Watch! if someone stars it.

Tunneling

Tunneling can be enabled using localtunnel.me, you just have to enable it in the config.toml and indicate a desired subdomain using the tunnelName field. If no tunnelName is provided then localtunnel.me will give you a random subdomain, this subdomain is printed in the console logs.

Really running

harpoon

or to have it verbose (use -vt also if you want logs about localtunnel.me):

harpoon -v

It will output something like this when running:

    __
   / /_  ____ __________  ____  ____  ____
  / __ \/ __ `/ ___/ __ \/ __ \/ __ \/ __ \
 / / / / /_/ / /  / /_/ / /_/ / /_/ / / / /
/_/ /_/\__,_/_/  / .___/\____/\____/_/ /_/
                /_/
	Listening on 0.0.0.0:9001
    
push detected on foo/bar with ref refs/heads/develop with the following commits:
	2016-03-08 13:59:38 +0100 CET - adding some awesomeness by Foo Bar
	2016-03-08 13:59:57 +0100 CET - forgot the unicorn png by Foo Bar
	2016-03-08 14:01:12 +0100 CET - so much joy in one commit by Foo Bar
> Push!

Obviously, the command should be something like /path/to/pull-build-n-deploy.sh where some awesome stuff is going on. Like something involving git, maven, rake, npm, bower, I don't know, this is your job :)

Security

POST requests made by GitHub are validated against the X-Hub-Signature if the environment variable GITHUB_HOOK_SECRET_TOKEN is set. It must be the same as the one defined on the GitHub's WebHook page.

Thanks

Licence

MIT

harpoon's People

Contributors

agrison avatar jakdept avatar jsgv avatar loop0 avatar scottmansfield avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

harpoon's Issues

Bitbucket ?

Do you know if this works with bitbucket ?
Also if I run this on a computerthat's behind NAT, how is the program alerted to changes in the git server ? Is it polling ?

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.