GitAutoDeploy.py 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 you projects each time you push new commits to your repository.
When commits are pushed to your Git repository, the Git server will notify GitAutoDeploy.py
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. GitAutoDeploy.py parses and validates the request, and if all goes well it issues a git pull
.
Additionally, GitAutoDeploy.py
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.
- Git (tested on version 2.5.0)
- Python (tested on version 2.7)
- Copy
GitAutoDeploy.conf.json.example
toGitAutoDeploy.conf.json
- Modify
GitAutoDeploy.conf.json
to match your project setup - Make sure that the
pidfilepath
path is writable for the user running the script, as well as any other path configured for your repositories.
python GitAutoDeploy.py
--daemon-mode (-d) Run in background (daemon mode) --quiet (-q) Suppress all output --ssh-keygen --force --config Specify custom configuration file
The easiest way to configure your system to automatically start GitAutoDeploy.py
after a reboot is through crontab. Open crontab in edit mode using crontab -e
and add the following:
@reboot /usr/bin/python /path/to/GitAutoDeploy.py --daemon-mode --quiet
- Copy file
initfiles/debianLSBInitScripts/gitautodeploy
to/etc/init.d/
- Make it executable:
chmod 755 /etc/init.d/gitautodeploy
- Also you need to make
GitAutoDeploy.py
executable (if it isn't already):chmod 755 GitAutoDeploy.py
- This init script assumes that you have
GitAutoDeploy.py
installed in/opt/Git-Auto-Deploy/
and that thepidfilepath
config option is set to/var/run/gitautodeploy.pid
. If this is not the case, edit thegitautodeploy
init script and modifyDAEMON
,PWD
andPIDFILE
. - Now you need to add the correct symbolic link to your specific runlevel dir to get the script executed on each start up. On Debian_Sys-V just do
update-rc.d gitautodeploy defaults
- Copy file
initfiles/systemd/gitautodeploy.service
to/etc/systemd/system
- Also you need to make
GitAutoDeploy.py
executable (if it isn't already):chmod 755 GitAutoDeploy.py
- And also you need to create the user and the group
www-data
if those not existsuseradd -U www-data
- This init script assumes that you have
GitAutoDeploy.py
installed in/opt/Git-Auto-Deploy/
. If this is not the case, edit thegitautodeploy.service
service file and modifyExecStart
andWorkingDirectory
. - now reload daemons
systemctl daemon-reload
- Fire it up
systemctl start gitautodeploy
- Make is start on system boot
systemctl enable gitautodeploy
- Go to your repository -> Settings -> Webhooks and Services -> Add webhook
- In "Payload URL", enter your hostname and port (your-host:8001)
- Hit "Add webhook"
- Go to your repository -> Settings -> Web hooks
- In "URL", enter your hostname and port (your-host:8001)
- Hit "Add Web Hook"
- Go to your repository -> Settings -> Webhooks -> Add webhook
- In "URL", enter your hostname and port (your-host:8001)
- Hit "Save"