Categorygithub.com/mumblez/github-webhook
repositorypackage
0.0.3
Repository: https://github.com/mumblez/github-webhook.git
Documentation: pkg.go.dev

# README

github webhook

Super simple single purpose app to handle incoming webhook request from github and to auth with secret!

After authorising the request, we check the branch and repository url in the payload and if it matches we refresh the repository on disk. We only handle a single repository!

Prerequisites

  • Generate an ssh key pair (with passphrase) and put the public key as a new Deploy key for the repo we want to update (on github)
  • Generate a webhook for the repository with a secret, path and set the application type to json
  • Ensure the user the service is running as can write to the repository directory (to clone / pull)

Configuration

Order of precedence:

  1. Command line options
  2. Environment variables
  3. Configuration file
  4. Default values
TypeCLI FlagEnvironment (all prefixed with GHW_)FileDefault ValueNotes
int-port 1010PORT=1010port 10104567TCP port to listen
string-path /payloadPATH="/payload"path /payload/payloadURI path, e.g. https://domain.com/payload
string-secret gitHubWebHookSecret12345SECRET="gitHubWebHookSecret12345"secret gitHubWebHookSecret12345webhook secret set on github
string-repo_ssh_key /path/to/private/keyREPO_SSH_KEY="/path/to/private/key"repo_ssh_key /path/to/private/keypath to ssh private key (deploy key)
string-repo_ssh_pass sshPassphrase123REPO_SSH_PASS="sshPassphrase123"repo_ssh_pass sshPassphrase123passphrase to ssh key
string-repo_url [email protected]:ns/repo.gitREPO_URL="[email protected]:ns/repo.git"repo_url [email protected]:ns/repo.gitgit url (ssh, not http)
string-repo_branch masterREPO_BRANCH="master"repo_branch mastermasterbranch to clone / update
string-repo_dir /path/to/clone/toREPO_DIR="/path/to/clone/to"repo_dir /path/to/clone/tolocal directory to clone repository to
int-health_check_port 9091HEALTH_CHECK_PORT=9091health_check_port 90919091port to handle health check
string-health_check_path /pingHEALTH_CHECK_PATH="/ping"health_check_path /ping/pingpath to handle health check

If we set a configuration file, pass the path to -config on the cli