Sign inSign up

fukamachi/github-webhook

By fukamachi

Updated about 5 years ago

Docker container to listen for GitHub webhook events.

Image
0

1.7K

fukamachi/github-webhook repository overview

github-webhook

Docker container to listen for GitHub webhook events.

Usage

$ docker run -it -v ${PWD}/hooks:/app/hooks -p 5000:5000 fukamachi/github-webhook

github-webhook server will invoke scripts under /app/hooks when getting webhook requests.

Hooks directory structure

github-webhook determines which hook scripts to run by its subdirectories. (eg. hooks/<event>/<action>/*)

The structure is something like this:

+ hooks/
  + push/
    - run-when-pushed.sh
  + issue/
    - run-on-all-issue-events.sh
    + created/
      - run-when-issue-is-created.sh
  + package/
    - run-on-all-package-events.sh
    + published/
      - run-when-package-is-published.sh

Configurable variables

  • GH_HOOKS_DIR: Directory path of hook scripts (Default: /app/hooks)
  • GH_SECRET: GitHub Webhook secret token (Optional)
Examples
# Using custom location for hook scripts
$ docker run -it -v ${PWD}/hooks:/code/hook-scripts -p 5000:5000 -e GH_HOOKS_DIR=/code/hook-scripts fukamachi/github-webhook

# Using secret token to refuse requests from other than GitHub
$ docker run -it -v ${PWD}/hooks:/app/hooks -p 5000:5000 -e GH_SECRET=xxxxxxxxxxxxxxxxxxx fukamachi/github-webhook

Writing Hooks

Available environment variables
namedescriptionexample
GH_HOOK_EVENT_NAMEEvent name of the webhook.push, issue, package
GH_HOOK_EVENT_PATHFile path to store the whole payload./tmp/event-xxxxxx.json
GH_HOOK_ACTIONAction name of the webhook.created, published
GH_HOOK_SENDERUser name that triggered the event.fukamachi
GH_HOOK_REPOSITORYRepository full name.fukamachi/clack
GH_HOOK_REPOSITORY_OWNERRepository owner name.fukamachi
GH_HOOK_REPOSITORY_NAMERepository name.clack
GH_HOOK_ORGANIZATIONOrganization name of the event.pokepay
GH_HOOK_REFGit reference.1da31df21ef7a87a296c954f59a9154b99f4f21f
GH_HOOK_BRANCHGit branch name. This is an empty string if the event isn't related to a branch.master, production
GH_HOOK_TAGGit tag name. This is an empty string if the event isn't related to a tagv1.0.0
GH_HOOK_PACKAGE_NAMEPackage name. This is an empty string unless the event is package.hello-world
GH_HOOK_PACKAGE_TYPEPackage type. This is an empty string unless the event is package.npm
GH_HOOK_PACKAGE_VERSIONPackage version. This is an empty string unless the event is package.1.0.0

Author

License

Licensed under the BSD 2-Clause License.

Tag summary

Content type

Image

Digest

Size

332.4 MB

Last updated

about 5 years ago

docker pull fukamachi/github-webhook