What is it?
Git-Auto-Deploy consists of a small HTTP server that listens for Web hook requests sent from GitHub, GitLab or Bitbucket servers. This application allows you to continuously and automatically deploy your projects each time you push new commits to your repository.
How does it work?
When commits are pushed to your Git repository, the Git server will notify Git-Auto-Deploy
by sending a HTTP POST request with a JSON body to a pre configured URL (your-host:8001). The JSON body contains detailed information about the repository and what event that triggered the request. Git-Auto-Deploy
parses and validates the request, and if all goes well it issues a git pull
.
Additionally, Git-Auto-Deploy
can be configured to execute a shell command upon each successful git pull
, which can be used to trigger custom build actions or test scripts.
Getting started
Install from repository (recommended)
When installing Git-Auto-Deploy
from the repository, you'll need to make sure that Python (tested on version 2.7) and Git (tested on version 2.5.0) is installed on your system.
Clone the repository and go into the repository root
git clone https://github.com/olipo186/Git-Auto-Deploy.git
cd Git-Auto-Deploy
Make a copy of the sample configuration file and modify it to match your project setup. Read more about the configuration options.
cp config.json.sample config.json
Tip: Make sure that the path specified in pidfilepath
is writable for the user running the script, as well as any other path configured for your repositories.
Run the application my invoking python
and referencing the gitautodeploy
module (the directory Git-Auto-Deploy/gitautodeploy
).
python gitautodeploy
To start Git-Auto-Deploy
automatically after a reboot, you can use crontab. Open crontab in edit mode using crontab -e
and add the entry below.
@reboot /usr/bin/python /path/to/Git-Auto-Deploy/gitautodeploy --daemon-mode --quiet --config /path/to/git-auto-deploy.conf.json
Tip: You can also configure Git-Auto-Deploy
to start automatically using a init.d-script (for Debian and Sys-V like init systems) or a service for systemd. Read more about starting Git-Auto-Deploy automatically using init.d or systemd.
Install from PPA (recommended for debian systems)
Add our PPA repository
sudo add-apt-repository ppa:olipo186/git-auto-deploy
sudo apt-get update
Install Git-Auto-Deploy
using apt
sudo apt-get install git-auto-deploy
Modify the configuration file to match your project setup. Read more about the configuration options.
nano /etc/git-auto-deploy.conf.json
Start Git-Auto-Deploy
and check it's status
service git-auto-deploy start
service git-auto-deploy status
Alternative installation methods
- Install as a python module (experimental)
- Install as a debian package (experimental)
- Start automatically on boot (init.d and systemd)
Command line options
Below is a summarized list of the most common command line options. For a full list of available command line options, invoke the application with the argument --help
or read the documentation article about all available command line options, environment variables and config attributes.
Command line option | Environment variable | Config attribute | Description |
---|---|---|---|
--daemon-mode (-d) | GAD_DAEMON_MODE | Run in background (daemon mode) | |
--quiet (-q) | GAD_QUIET | Supress console output | |
--config (-c) | GAD_CONFIG | Custom configuration file | |
--pid-file | GAD_PID_FILE | pidfilepath | Specify a custom pid file |
--log-file | GAD_LOG_FILE | logfilepath | Specify a log file |
--host | GAD_HOST | host | Address to bind to |
--port | GAD_PORT | port | Port to bind to |
Getting webhooks from git
To make your git provider send notifications to Git-Auto-Deploy
you will need to provide the hostname and port for your Git-Auto-Deploy
instance. Instructions for the most common git providers is listed below.
GitHub 1. Go to your repository -> Settings -> Webhooks and Services -> Add webhook 2. In "Payload URL", enter your hostname and port (your-host:8001) 3. Hit "Add webhook"
GitLab 1. Go to your repository -> Settings -> Web hooks 2. In "URL", enter your hostname and port (your-host:8001) 3. Hit "Add Web Hook"
Bitbucket 1. Go to your repository -> Settings -> Webhooks -> Add webhook 2. In "URL", enter your hostname and port (your-host:8001) 3. Hit "Save"
More documentation
Have a look in the docs directory, where you'll find more detailed documentation on configurations, alternative installation methods and example workflows.