{"id":19541427,"url":"https://github.com/ickk/hook","last_synced_at":"2026-05-14T11:38:23.947Z","repository":{"id":134717698,"uuid":"361421648","full_name":"ickk/hook","owner":"ickk","description":"A simple webserver intended to respond to webhook events.","archived":false,"fork":false,"pushed_at":"2021-05-15T09:09:55.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-01-08T18:45:26.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ickk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-25T12:24:10.000Z","updated_at":"2021-05-15T09:26:05.000Z","dependencies_parsed_at":"2023-06-02T19:30:20.977Z","dependency_job_id":null,"html_url":"https://github.com/ickk/hook","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Fhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Fhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Fhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ickk%2Fhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ickk","download_url":"https://codeload.github.com/ickk/hook/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240795165,"owners_count":19858758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T03:10:27.931Z","updated_at":"2026-05-14T11:38:18.926Z","avatar_url":"https://github.com/ickk.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Hook\n====\n\nHook is a simple webserver intended to respond to webhook events.\n\n\nCurrently Hook has a Git module that will respond to GitHub Webhook *push*\nevents. One use-case is to host the source code of a website in a git\nrepository and use Hook to allow easily updating the live website by pushing\nchanges to the repository.\n\n\nOther kinds of webhooks responses should be straight-forward to add without\nchanging the overall architecture of Hook.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**\n\n  - [Configuration](#configuration)\n- [Modules](#modules)\n  - [Git](#git)\n    - [Configuration](#configuration-1)\n- [Build Instructions](#build-instructions)\n- [Architecture](#architecture)\n  - [Git](#git-1)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n### Configuration ###\n\nHook reads all it's configuration values from\n[RON](https://github.com/ron-rs/ron) formatted configuration files found in a\n`config/` folder relative to the current working directory when running the\nHook binary: `$PWD/config/*.ron`.\n\n\nHook itself takes some configuration options:\n\n\n`config/hook.ron`:\n```ron\n(\n  address: \"localhost\",\n  port: 7267,\n  url_base: \"/hook\",\n  modules: [\n    Git (mount_path: \"/git\"),\n  ],\n)\n```\n\n* `address` and `port` are the interface to serve Hook at.\n* `url_base` should be set if Hook is being served at a path by a reverse proxy\n  instead of from the site root. The base path will be prepended to any\n  internally generated urls to correct for the reverse proxy.\n* `modules` takes a list of Hook modules to enable, and each module takes a\n  `mount_path` that it will be served under.\n\n\nConfiguration of individual modules is covered in each [Modules](#modules)\nsubsection.\n\n\nModules\n-------\n\n### Git ###\n\nThe Git module will respond to [Github webhook events](https://docs.github.com/en/developers/webhooks-and-events/about-webhooks\u003e`).\n\n\nThe *push* event is currently supported with a corresponding *pull* action,\nallowing Hook to automatically pull changes into a git repository when new\nchanges are available on the remote. Basic validation of the event is done;\nHTTP headers are checked, the HMAC signature of the event is verified.\n\n\nTo use the Git module, it must first be enabled in the `config/hook.ron`\nconfiguration file:\n\n\n#### Configuration ####\n\n`config/hook.ron`:\n```ron\n(\n  modules: [\n    Git (mount_path: \"/git\"),\n  ],\n)\n```\n\n\nThen the Git module can be configured with the `config/git.ron` configuration\nfile:\n\n\n`config/git.ron`:\n```ron\n(\n  policies: [\n    ( service: Github,\n      repo_name: \"user_a/repository_1\",\n      secret: \"super_secret_74830921478320147830214783021478187\",\n      event: Push,\n      action: Pull (path: \"/home/user_a/repository_1\",\n                    remote: \"origin\",\n                    branch: \"main\",\n                    ssh_key_path: \"config/repository_1.id_rsa\") ),\n    ( service: Github,\n      repo_name: \"user_b/repository_2\",\n      secret: \"meta_secret_748930216874830214316248923017483201\",\n      event: Push,\n      action: Pull (path: \"/home/user_b/repository_2\",\n                    remote: \"origin\",\n                    branch: \"prod\",\n                    ssh_key_path: \"config/repository_2.id_rsa\") ),\n  ],\n)\n```\n\n\n`policies` is a list of Policy definitions for which events to respond to and\n  what actions to take. For each Policy:\n\n* `service` takes the `Github` class.\n* `repo_name` defines the *full repository name*. i.e. the\n  user_name/repository_name.\n* `secret` is the shared secret that is used to cryptographically sign\n  webhooks. It should be a long random string of characters.\n* `event` is the type of event to respond to. It takes the `Push` class to\n  respond to Github *push* webhook events.\n* `action` is the type of action to take in response to the event. The `action`\n  field takes a `Pull` class with it's own fields:\n  * `path`: The path of the git repository on the local disk.\n  * `remote`,`branch`: The git *remote* and *branch* to pull.\n  * `ssh_key_path`: The path to an ssh private key file authorized to pull from\n    the specified remote.\n\n\nNote: On Github you can add *read-only* ssh keys from the *Deploy keys* section\non a repository's settings page. It is recommended to use a Deploy key with\nunattended services such as Hook.\n\n\nBuild Instructions\n------------------\n\nDependencies:\n* [Rust/Cargo](https://rustup.rs),\n* GNUMake.\n\nBuild with:\n```sh\nmake build\n```\n\nRun with:\n```sh\n./hook\n```\nNote: First setup [configuration](#configuration) files.\n\n\nArchitecture\n------------\n\nHook is a [Rocket](https://rocket.rs/)-based web application. Rust modules form\ncollections of end-points related to a single service. Each module provides a\n`pub fn routes() -\u003e Vec\u003cRoute\u003e` implementation that returns all of the relevant\nRocket routes.\n\n\nA selection of modules are enabled in the `hook.ron` configuration file and\nthen `main.rs` mounts the specified modules to Hook's request router.\n\n\n### Git ###\n\nThe service and event type are pulled from the request's HTTP headers (In this\ncontext *service* refers to Github, Gitlab, etc. and *event* refers to pull,\npush, issue, etc.)\n\nMultiple request handlers may implement the `/\u003crepo_name\u003e` end-point, with each\nhandler targeting a different service/event combination to handle their\nservice-specific quirks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fickk%2Fhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fickk%2Fhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fickk%2Fhook/lists"}