MCPcopy Index your code
hub / github.com/WingLim/caddy-webhook

github.com/WingLim/caddy-webhook @v1.0.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.8 ↗ · + Follow
65 symbols 181 edges 16 files 14 documented · 22%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

caddy-webhook

Build License: MIT

Caddy v2 module for serving a webhook.

English | 中文

Installation

Build with xcaddy

xcaddy build \
  --with github.com/WingLim/caddy-webhook

Run in Docker

See caddy-docker for Dockerfile.

DockerHub: winglim/caddy

GitHub Package: winglim/caddy

Usage

Now supported webhook type:

  • github
  • gitlab
  • gitee
  • bitbucket
  • gogs

Caddyfile Format

Notice: webhook block should be the last handler of route. After receive request and handle it, we return nil instead of the next middleware. So, the rest handler after webhook will not work.

webhook [<repo> <path>] {
    repo       <text>
    path       <text>
    branch     <text>
    depth      <int>
    type       <text>
    secret     <text>
    command    <text>...
    key        <text>
    username   <text>
    password   <text>
    token      <text>
    submodule
}
  • repo - git repository url, supported http, https and ssh.
  • path - path to clone and update repository.
  • branch - branch to pull. Default is main.
  • depth - depth for pull. Default is 0.
  • type - webhook type. Default is github.
  • secret - secret to verify webhook request.
  • submodule - enable recurse submodules.
  • command - the command run when repo initializes or get the correct webhook request.
  • key - path of private key, using to access git with ssh.
  • username - username for http auth.
  • password - password for http auth.
  • token - GitHub personal access token.

Example

The full example to run a hugo blog:

Caddyfile:

example.com

root www
file_server

route /webhook {
    webhook {
        repo https://github.com/WingLim/winglim.github.io.git
        path blog
        branch hugo
        command hugo --destination ../www
        submodule   
    }
}

With the config above, webhook module will do things:

  1. Clone https://github.com/WingLim/winglim.github.io.git to blog when initializes.

    1. If the repo is already exist, will fetch and checkout to the branch you set.
  2. Run the command hugo --destination ../www inside the blog directory.

  3. Listen and serve at /webhook and handle the webhook request.

    1. When receive correct webhook request, will update repo and do step 2 again.

Thanks to

Extension points exported contracts — how you extend this code

HookService (Interface)
(no doc) [5 implementers]
webhooks/hookservice.go

Core symbols most depended-on inside this repo

getRepoNameFromURL
called by 2
webhook.go
isEmptyOrGit
called by 2
webhook.go
Run
called by 2
command.go
handleSignature
called by 2
webhooks/gogs.go
NewRepo
called by 1
repository.go
Setup
called by 1
repository.go
Update
called by 1
repository.go
fetch
called by 1
repository.go

Shape

Method 31
Struct 17
Function 16
Interface 1

Languages

Go100%

Modules by API surface

webhook.go10 symbols
webhooks/bitbucket.go9 symbols
repository.go8 symbols
webhooks/github.go7 symbols
webhooks/gogs.go5 symbols
webhooks/gitlab.go5 symbols
webhooks/gitee.go5 symbols
webhooks/hookservice.go3 symbols
command.go3 symbols
webhooks/gogs_test.go2 symbols
webhook_test.go2 symbols
caddyfile.go2 symbols

For agents

$ claude mcp add caddy-webhook \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact