• Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GitHub WebHook server written in Go

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

More Repositories

1

go-tablib

Go Module for Tabular Datasets in CSV, JSON, YAML, etc.
Go
143
star
2

jtoml

TOML for Java
Java
46
star
3

redux4j

Java implementation of redux with Vavr
Java
38
star
4

go-commons-lang

go-commons-lang
Go
25
star
5

jssg

Java static site generator
Java
20
star
6

advent-of-code

Solutions to the Advent of Code editions, mainly using Kotlin.
Kotlin
18
star
7

cljwebauthn

Webauthn for Clojure
Clojure
14
star
8

raytraclj

A raytracer implementation in Clojure
Clojure
12
star
9

covid19-babashka

Clojure
10
star
10

scalocco

Scalocco, a quick and dirty implementation of Docco in Scala
Scala
9
star
11

catastrophic

Catastrophic: a Monster Component in Java & Spring
Java
8
star
12

ocamail

Simple SMTP Server in OCaml
OCaml
6
star
13

realworld-server-tester

Realworld sample app backend tester
Clojure
5
star
14

duct-mongodb

Integrant methods for connecting to a MongoDB database via Monger
Clojure
5
star
15

vavr-matchers

Hamcrest matchers for Vavr
Java
3
star
16

springboot-backend-interview

Spring Boot Backend interview exercise
Java
3
star
17

legacy4j

Legacy flat files for Java
Java
2
star
18

monkey-kotlin

Writing an interpreter in Kotlin
Kotlin
2
star
19

isfates-c-2018

HTML
2
star
20

sermonis

sermonis
JavaScript
2
star
21

duct-elasticsearch

Integrant multimethods for connecting to ElasticSearch via Spandex.
Clojure
2
star
22

kree

Simple indentation Guide for Eclipse
1
star
23

duct-immutant

Integrant methods for running an Immutant web server
Clojure
1
star
24

clean-fb-wall

Clean your Facebook Wall
1
star
25

vavr-try-refactoring

Java
1
star
26

clojure-north-2020-fp-katas

Clojure
1
star
27

grison.me

Website pulled by DryDrop on Google App Engine
CSS
1
star