A tiny and dirty continuous integration script to deploy web projects
Receives webhooks from GitHub or GitLab (or any other solution via a new plugin) for selected projects and pull their content into specified directory.
- Go environment
libgit2
First, go get github.com/reveliant/dirtyci
then :
- either build directly with Go :
go build github.com/reveliant/dirtyci go build -buildmode=plugin github.com/reveliant/dirtyci/plugins/github go build -buildmode=plugin github.com/reveliant/dirtyci/plugins/gitlab
- or build with
make
(plugins are built in theplugins
directory) :cd $GOPATH/src/github.com/reveliant/dirtyci; make
- Create a Deploy Key for the dirtyci process owner (not necessary if you indend to only fetch via HTTPS access).
- Create a configuration file (see Configuration section below) Configure dirtyci (example configuration files are available in the repository)
- Start dirtyci. The following options are supported:
-c
: configuration file to use. Default:config.toml
-d
: enable Gin debug mode-host IFACE
: interface to listen to (address or hostname). Default:127.0.0.1
-port PORT
: port to listen to. Default:26979
(ci
string in decimal)
- Add the Deploy Key to your project
- A read-only access is sufficent
- Not necessary if you only fetch repository via HTTPS
git clone
your project on your web server- Create a new webhook pointing the script
- on GitHub, choose
application/json
for content type and checkJust the push event
- on GitLab, check
Push events
- on GitHub, choose
- Add the project to the
repositories
section of the config file (see Configuration section below)
The configuration file, either at JSON, YAML or TOML format, has 3 sections:
pluginsDir = "./plugins"
[plugins]
github = "/github"
gitlab = "/gitlab"
pluginsDir
define path to the directory containing plugins (.so
files).
If the path is relative, it will be to the current working dir. Therefore, it is recommanded to rather use absolute path.
Each plugin in the [plugins]
section will be loaded and set as a
new handler for GET and POST requests on the specified URI. Here :
github
plugin (github.so
) will handleGET /github
andPOST /github
requestsgitlab
plugin (github.so
) will handleGET /gitlab
andPOST /gitlab
requests
[defaults]
publicKeyPath = "$HOME/.ssh/id_rsa.pub"
privateKeyPath = "$HOME/.ssh/id_rsa"
remoteName = "origin"
remoteBranch = "master"
localBranch = "master"
(Harcoded default settings are indicated above, but note that variables are not supported)
publicKeyPath
andprivateKeyPath
: paths to SSH public and private keyremoteName
: name of Git remote (git clone
set it toorigin
by default)remoteBranch
: name of Git remote branch (git clone
will clonemaster
by default)localBranch
: name of Git local branch to merge into (currently not supported)
[[repositories]]
remoteUrl = "https://github.com/reveliant/dirtyci"
localUrl = "/var/www/dirtyci"
Additionnal to settings already defined in the [defaults]
section (which would
then be overwritten), the following settings are required for each repository:
remoteUrl
: unique identifier for external repository (read by the plugin)localUrl
: local path to the cloned repository to merge into
Several repositories entries can have the same localUrl
(for example to sync
both from GitHub and Gitlab, just set the remoteName
accordingly)
Considering we'll only pull from the repository, a read-only access is sufficent.
This step is not necessary if you use HTTPS access to repository.
MIT License