diff options
author | Alexander Nestorov <alexandernst@gmail.com> | 2014-09-19 10:37:42 +0200 |
---|---|---|
committer | Alexander Nestorov <alexandernst@gmail.com> | 2014-09-19 10:37:51 +0200 |
commit | 40c408413a816f39adef2edeb8124f21c1fe1a1c (patch) | |
tree | 9ec02e0e0ad5d2043dac0f20c77498f889756ffc | |
parent | d64e036eeafed4e8c8ba6b105408d62f405c64c3 (diff) | |
download | Git-Auto-Deploy-40c408413a816f39adef2edeb8124f21c1fe1a1c.zip Git-Auto-Deploy-40c408413a816f39adef2edeb8124f21c1fe1a1c.tar.gz Git-Auto-Deploy-40c408413a816f39adef2edeb8124f21c1fe1a1c.tar.bz2 |
Add global deploy commands
-rw-r--r-- | GitAutoDeploy.conf.json.example | 12 | ||||
-rwxr-xr-x | GitAutoDeploy.py | 19 | ||||
-rw-r--r-- | README.textile | 14 |
3 files changed, 32 insertions, 13 deletions
diff --git a/GitAutoDeploy.conf.json.example b/GitAutoDeploy.conf.json.example index 35aba2d..2f13ae9 100644 --- a/GitAutoDeploy.conf.json.example +++ b/GitAutoDeploy.conf.json.example @@ -1,11 +1,15 @@ { - "port": 8001, - "repositories": + "port": 8001, + "global_deploy": [ + "echo Starting deploy!", + "echo Ending deploy!" + ], + "repositories": [{ - "url": "https://github.com/logsol/Test-Repo", + "url": "https://github.com/logsol/Test-Repo", "path": "/home/logsol/projects/Test-Repo", "deploy": "echo deploying" - }, + }, { "url": "https://github.com/logsol/Katharsis-Framework", "path": "/home/logsol/projects/Katharsis-Framework" diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 00b852e..84ebd27 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -83,10 +83,23 @@ class GitAutoDeploy(BaseHTTPRequestHandler): config = self.getConfig() for repository in config['repositories']: if(repository['path'] == path): + cmds = [] if 'deploy' in repository: - if(not self.quiet): - print 'Executing deploy command' - call(['cd "' + path + '" && ' + repository['deploy']], shell=True) + cmds.append(repository['deploy']) + + gd = config['global_deploy'] + print gd + if len(gd[0]) is not 0: + cmds.insert(0, gd[0]) + if len(gd[1]) is not 0: + cmds.append(gd[1]) + + if(not self.quiet): + print 'Executing deploy command(s)' + print cmds + for cmd in cmds: + call(['cd "' + path + '" && ' + cmd], shell=True) + break diff --git a/README.textile b/README.textile index 81fc536..400a4ae 100644 --- a/README.textile +++ b/README.textile @@ -2,28 +2,30 @@ h1. What is it? -this is a small HTTP server written in python. +this is a small HTTP server written in python. It allows you to have a version of your project installed, that will be updated automatically on each Github or Gitlab push. To set it up, do the following: * install python * copy the GitAutoDeploy.conf.json.example to GitAutoDeploy.conf.json. This file will be gitignored and can be environment specific. * enter the matching for your project(s) in the GitAutoDeploy.conf.json file -* start the server by typing "python GitAutoDeploy.py" +* start the server by typing "python GitAutoDeploy.py" * to run it as a daemon add ==--daemon-mode== -* On the Github or Gitlab page go to a repository, then "Admin", "Service Hooks", +* On the Github or Gitlab page go to a repository, then "Admin", "Service Hooks", "Post-Receive URLs" and add the url of your machine + port (e.g. http://example.com:8001). You can even test the whole thing here, by clicking on the "Test Hook" button, whohoo! h1. How this works -When someone pushes changes into Github or Gitlab, it sends a json file to the service hook url. +When someone pushes changes into Github or Gitlab, it sends a json file to the service hook url. It contains information about the repository that was updated. -All it really does is match the repository urls to your local repository paths in the config file, +All it really does is match the repository urls to your local repository paths in the config file, move there and run "git pull". -Additionally it runs a deploy bash command that you can add to the config file optionally. +Additionally it runs a deploy bash command that you can add to the config file optionally, and it also +allows you to add two global deploy commands, one that would run at the beginning and one that would run +at the end of the deploy. Make sure that you start the server as the user that is allowed to pull from the github or gitlab repository. |