Code Monkey home page Code Monkey logo

caddygit's Introduction

caddygit

Git module for Caddy v2

The module is helpful in creating git clients that pull from the given repository at regular intervals of time (poll service) or whenever there is a change in the repository (webhook service). On a successful pull it runs the specified commands to automate deployment.

Installation

Simply add the following import to cmd/caddy/main.go and build the caddy binary:

package main

import (
	caddycmd "github.com/caddyserver/caddy/v2/cmd"

	// plug in Caddy modules here
	_ "github.com/caddyserver/caddy/v2/modules/standard"
	_ "github.com/vrongmeal/caddygit/module/git" // Yay!!!
)

func main() {
	caddycmd.Main()
}

OR you can use xcaddy to build:

$ xcaddy build v2.1.1 \
    --with github.com/vrongmeal/caddygit/module/git

API structure

{
    // Your caddy apps.
    "apps": {
        // Git app module.
        "git": {
            // Your git clients to be deployed.
            "clients": [
                // Example client.
                {
                    // Git repository info.
                    "repo": {
                        // HTTP URL of the git repository.
                        "url": "http://github.com/vrongmeal/caddygit",

                        // Path to clone the repository in. If path specified
                        // exists and is a git repository, it simply opens the
                        // repo. If the path is not a repo and does not exist,
                        // it creates a repo in that path.
                        "path": "/path/to/clone",

                        // Branch (or tag) of the repository to clone. Defaults
                        // to `master`.
                        "branch": "my-branch",

                        // Username and secret for authentication of private
                        // repositories. If authenticating via access token,
                        // set the auth_secret equal to the value of access token
                        // and auth_user can be omitted.
                        "auth_user": "vrongmeal",
                        "auth_secret": "password",

                        // Specifies whether to clone only the specified branch.
                        "single_branch": true,

                        // Depth of commits to fetch.
                        "depth": 1
                    },
                    // Service info.
                    "service": {
                        // Type of the service.
                        // Services supported: poll, webhook
                        "type": "poll",

                        // Interval after which service will tick.
                        "interval": "10m"
                    },
                    // Commands to run after every update.
                    "commands_after": [
                        {
                            // Command to execute.
                            "command": ["echo", "hello world"],

                            // Whether to run command in background (async).
                            // Defaults to false.
                            "async": true
                        }
                    ]
                }
            ]
        }
    }
}

TODO:

  • Support for Caddyfile
  • Webhook service

caddygit's People

Contributors

vrongmeal avatar

Watchers

 avatar

Forkers

rigon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.