Skip to content

greenpau/caddy-git

Repository files navigation

caddy-git

Git Plugin for Caddy v2.

Inspired by this comment.

Please ask questions either here or via LinkedIn. I am happy to help you! @greenpau

Please see other plugins:

Table of Contents

Overview

The caddy-git allows updating a directory backed by a git repo.

Getting Started

Configuration examples:

For example, the following configuration sets up a definition for authp.github.io repo. The request to authp.myfiosgateway.com/update/authp.github.io trigger git pull of the authp.github.io repository.

{
  git {
    repo authp.github.io {
      base_dir /tmp
      url https://github.com/authp/authp.github.io.git
      branch gh-pages
      post pull exec {
        name Pager
        command /usr/bin/echo
        args "pulled authp.github.io repo"
      }
    }
  }
}

authp.myfiosgateway.com {
  route /version* {
    respond * "1.0.0" 200
  }
  route /update/authp.github.io {
    git update repo authp.github.io
  }
  route {
    file_server {
      root /tmp/authp.github.io
    }
  }
}

The cloning of the repository happens on startup. Additionally, the cloning happens when /update/authp.github.io is being hit.

curl https://authp.myfiosgateway.com/update/authp.github.io