This is a simple deployer written in go, using git.
gg-deployer [--debug] -c <config.json>
config.json
is the configuration file. Its content is like:
{
// how many worker go-routines to prepare for incoming deploy jobs
"max_workers": 5,
// the configuration of HTTP server
"http_server": {
"host": "0.0.0.0", // which host to listen on
"port": 8088 // which port to listen on
},
// define projects
"projects": [
{
// Only github and gogs are supported now
"type": "github",
// The github repo full name (case sensitive)
"repo": "someuser/somerepo",
// The repo URL to pull the repo down.
// It can be omitted if type is github. If omitted, default repo_url is git@github.com:<repo>.git
"repo_url": "git@github.com:someuser/somerepo.git",
// The secret you enter in the push event configuration page.
"secret": "!!EnterYourSecretHere!!",
// Where to store the repo.
// It should be a private path. And you must NOT change its content.
"store": "/path/to/store/the/repo",
// Where to deploy the project.
"target": "/path/to/deploy/target",
// Which branch to deploy(checkout).
"branch": "master",
// as which user to run the deploy command
"run_as": "www",
// script to run after checkout/pull done, in store directory.
"post_checkout_script": "echo This is post checkout script",
// script to run after rsync done, in target directory
"post_rsync_script": "echo This is post rsync script",
// override default deploy commands.
// if `$exec` is not empty, only `$exec` will be executed. default checkout and rsync command will be ignored.
"exec": ""
},
{
"type": "gogs",
"repo": "someuser/somerepo",
"repo_url": "git@git.xxxx.com:someuser/somerepo.git",
"secret": "!!EnterYourSecretHere!!",
"store": "/path/to/store/the/repo",
"target": "/path/to/deploy/target",
"branch": "master"
}
]
}
- Checkout or pull the latest
project.branch
intoproject.store
directory (which will be create if not exist). - Run
project.post_checkout_script
inproject.store
directory. - Use
rsync
to synchronize files fromproject.store
toproject.target
. (.rsync_ignores
file will be used if it exists inproject.store
directory) - Run
project.post_rsync_script
inproject.target
directory.
You can use "run_as" field to specify which user to run the commands.