# Packages
# README
JoJo's Bizarre webhook handler
ゴゴゴゴゴゴ !
Josuke is a tiny CI/deployment tool that reacts on Github/Bitbucket webhook's payload.
Josuke is a simple guy, 3 things and he's happy:
- Write a JSON config file
- Run Josuke and feed him your config
- Go to Github/Bitbucket and set webhooks routes as specified in your config
Writing a json config file is required.
Config file path must be given using the -c flag (josuke -c /path/to/config.json).
Example of a classic config.json:
{
"github_hook": "/josuke/github",
"bitbucket_hook": "/josuke/bitbucket",
"host": "127.0.0.1",
"port": 8082,
"deployment":
[
{
"repo": "monkeydioude/donut",
"proj_dir": "donut",
"base_dir": "/var/www",
"branches":
[
{
"branch" :"master",
"actions":
[
{
"action": "push",
"commands": [
["cd", "%base_dir%"],
["git", "clone", "%html_url%"],
["cd", "%proj_dir%"],
["git", "pull", "--rebase"],
["make"]
]
}
]
}
]
}
]
}
TLS configuration
Add the cert
and key
properties inside config's json file, same level as github_hook
, bitbucket_hook
etc...
{
"…": "…",
"port": 8082,
"cert": "conf/cert.pem",
"key": "conf/key.pem",
"…": "…"
}
Generate the default certificate and private key with:
#!/bin/sh
openssl req -x509 -newkey rsa:4096 -nodes \
-out cert.pem \
-keyout key.pem -days 365
Keys definition
github_hook
: route Josuke will be receiving Github's payload. Must be specified in Github Webhooks' parametersbitbucket_hook
: route Josuke will be receiving Bitbuckets's payload. Must be specified in Bitbuckets Webhooks' parametersport
: port Josuke will listen todeployment
: array of objects defining deployments repository rules Josuke should follow.
These repository rules objects are defined as such:
repo
: name of your repository in the repository universe. No need to specify the whole only the username and repository name is required (ex: monkeydioude/josuke)branches
: is an array of objects defining the branche behavior towards specified branches.base_dir
: OPTIONAL Allow you to set what should be a base directory usable at commands definition level (ex: /var/projects/sources)proj_dir
: OPTIONAL Allow you to set what should be a project directory (or name) usable at commands definition level
branch behaviors objects are defined as such:
branch
: behavior toward a specific branchactions
: is an array of objects defining the behavior towards specific actions.
actions objects are defined as such:
action
: is the kind of action sent by the payload, that has been taken toward the source branch (ex: push on a branch, merge a branch with the source branch...)commands
: is an array of objects defining the series of commands Josuke should trigger for thisaction
commands is an array of array of strings that should contain commands to be executed when an action
is triggered. 1st index of the array must be the command name. Every following index should be args of the command:
[
["cd", "%base_dir%"],
["git", "clone", "%html_url%"],
["cd", "%proj_dir%"],
["git", "pull", "--rebase"],
["make"]
]
Currently run on Linux systems only*
You can use these 3 Keywords at commands level
%base_dir%
: referring to "base_dir" set in config, must be defined bybase_dir
of eachdeployment
%proj_dir%
: referring to "proj_dir" set in config, must be defined byproj_dir
of eachdeployment
%html_url%
: retrieved from github/bitbucket's payload informations, html url of your repo
Incoming:
- Tests
- Docker image for testing/building
- Handle syscall for different OS
DORA !