All Projects → alexandru → Github Webhook Listener

alexandru / Github Webhook Listener

Licence: other
Light server for reacting to GitHub's Webhooks

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Github Webhook Listener

Abstruse
Abstruse is a free and open-source CI/CD platform that tests your models and code.
Stars: ✭ 704 (+3811.11%)
Mutual labels:  server
Multi Model Server
Multi Model Server is a tool for serving neural net models for inference
Stars: ✭ 770 (+4177.78%)
Mutual labels:  server
Monitorix
Monitorix is a free, open source, lightweight system monitoring tool.
Stars: ✭ 817 (+4438.89%)
Mutual labels:  server
Minet
A (not so) basic Minecraft Pocket Edition server written in C#
Stars: ✭ 706 (+3822.22%)
Mutual labels:  server
Casino Server
🔥 An online poker game server powered by Redis, node.js and socket.io
Stars: ✭ 721 (+3905.56%)
Mutual labels:  server
Deno Drash
A REST microframework for Deno's HTTP server with zero 3rd party dependencies.
Stars: ✭ 795 (+4316.67%)
Mutual labels:  server
Node Minecraft Protocol
Parse and serialize minecraft packets, plus authentication and encryption.
Stars: ✭ 697 (+3772.22%)
Mutual labels:  server
Orbit Db Http Api
A HTTP API Server for the OrbitDB distributed peer-to-peer database
Stars: ✭ 17 (-5.56%)
Mutual labels:  server
Mycat2
MySQL Proxy using Java NIO based on Sharding SQL,Calcite ,simple and fast
Stars: ✭ 750 (+4066.67%)
Mutual labels:  server
Atscan
Advanced dork Search & Mass Exploit Scanner
Stars: ✭ 817 (+4438.89%)
Mutual labels:  server
Cowyo
A feature-rich wiki webserver for minimalists 🐮 💬
Stars: ✭ 711 (+3850%)
Mutual labels:  server
Shell2http
Executing shell commands via HTTP server
Stars: ✭ 719 (+3894.44%)
Mutual labels:  server
Gonet
go分布式服务器,基于内存mmo
Stars: ✭ 804 (+4366.67%)
Mutual labels:  server
Vssh
Go Library to Execute Commands Over SSH at Scale
Stars: ✭ 707 (+3827.78%)
Mutual labels:  server
Hadoop For Geoevent
ArcGIS GeoEvent Server sample Hadoop connector for storing GeoEvents in HDFS.
Stars: ✭ 5 (-72.22%)
Mutual labels:  server
Generator Ng Fullstack
Client, server or fullstack - it's up to you. ng-fullstack gives you the best of the latest.
Stars: ✭ 701 (+3794.44%)
Mutual labels:  server
Webhook
webhook is a lightweight incoming webhook server to run shell commands
Stars: ✭ 7,201 (+39905.56%)
Mutual labels:  server
Angular Universal Seed
Angular5 Universal Webpack Seed
Stars: ✭ 17 (-5.56%)
Mutual labels:  server
Eurythmia Server
Eurythmia server repository: mods, subgame, configuration, issues tracker, and a few other.
Stars: ✭ 7 (-61.11%)
Mutual labels:  server
Dyson
Node server for dynamic, fake JSON.
Stars: ✭ 814 (+4422.22%)
Mutual labels:  server

github-webhook-listener

Build Deploy

A simple web app that can be registered as a GitHub Webhook and trigger shell commands in response to events.

Main use-case is to trigger refreshes of websites hosted on your own server via Travis-CI jobs, but in a secure way, without exposing server credentials or SSH keys.

The server process is also light in resource usage, not using more than 20 MB of RAM on a 64-bit Ubuntu machine, so it can be installed on under-powered servers.

Setup

Images are being pushed on Docker Hub and you can quickly run the process like this:

docker run \
  -p 8080:8080 \
  -ti alexelcu/github-webhook-listener

Server Configuration

On its own this just starts the server, but doesn't know how to do anything. We'll need to specify a configuration file: Create your ./config.yaml:

http:
  path: "/"
  port: 8080

runtime:
  workers: 2
  output: stdout

projects:
  myproject:
    ref: "refs/heads/gh-pages"
    directory: "/var/www/myproject"
    command: "git pull"
    secret: "xxxxxxxxxxxxxxxxxxxxxxxxxx"

Notes:

  1. myproject in project.myproject is just a name of a project, it could be anything
  2. ref says to only react on pushes to the gh-pages branch
  3. directory is where the command should be executed
  4. command is to be executed — note that git is already installed in the Docker image, doing git pull on a directory being the primary use case

It would be better if the git pull command would update files using a specified host user and group. And we'll also need an SSH key to install our "deployment key". So on your Linux box:

sudo adduser synchronize

sudo adduser synchronize www-data

sudo chown -R synchornize:www-data /var/www/myproject

And afterwards:

docker run \
  -p 8080:8080 \
  -v "$(pwd)/config.yaml:/opt/app/config/config.yaml" \
  -u "$(id -u synchronize):$(id -g synchronize)" \
  -ti alexelcu/github-webhook-listener

You could also use docker-compose, here's what I have on my own server:

version: '3.3'

services:
  github-webhook-listener:
    container_name: github-webhook-listener
    image: 'alexelcu/github-webhook-listener:latest'
    restart: unless-stopped
    ports:
      - "8080:8080"
    tty: true
    networks:
      - main
    volumes:
      - /var/www:/var/www
      - /etc/github-webhook-listener/config.yaml:/opt/app/config/config.yaml
    user: "${SYNC_UID}:${SYNC_GID}"

networks:
  main:
    external:
      name: main

Then to expose this server via Nginx, it's just a matter of configuring a proxy_pass:

location / {
  proxy_pass http://127.0.0.1:8080;
  proxy_set_header    Host            $host;
  proxy_set_header    X-Real-IP       $remote_addr;
  proxy_set_header    X-Forwarded-for $remote_addr;
  proxy_connect_timeout 300;
}

Configuring Your GitHub Project

Go to the settings page of your project, the "Webhooks" section, link should be like: https://github.com/<user>/<project>/settings/hooks

Setup screen for adding a new Webhook should look like this:

Webhook setup screen

NOTEs on those fields:

  1. the Payload URL contains a some-id, in the described path, that should be configured in your config.yaml file to identify your project
  2. the Secret is the passphrase you also configured in config.yaml — this is optional, but if the config.yaml mentions a passphrase which you're not mentioning in this setup, then requests will fail

Manual Setup (without Docker)

Wiki instructions for Setup

License

Copyright © 2018-2020 Alexandru Nedelcu, some rights reserved.

Licensed under the 3-Clause BSD License. See LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].