Skip to content

Commit 5aeb334

Browse files
committed
pull on get, see: logsol#14
1 parent c127104 commit 5aeb334

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ To set it up, do the following:
1111
* Enter the matching for your project(s) in the git_deploy.conf.json file
1212
* Start the server by typing "python git_deploy.py"
1313
* To run it as a daemon add --daemon-mode
14+
* To trigger the pull and deploy via get add --get-to-pull
1415
* On the Github 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).
1516

1617
You can even test the whole thing here, by clicking on the "Test Hook" button, whohoo!

git_deploy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class GitDeploy(BaseHTTPRequestHandler):
1414
quiet = False
1515
daemon = False
1616
branch = None
17+
is_get_available = False
1718

1819
@classmethod
1920
def get_config(cls):
@@ -33,6 +34,22 @@ def get_config(cls):
3334
and not os.path.isdir(repository['path'] + '/objects'):
3435
sys.exit('Directory ' + repository['path'] + ' is not a Git repository')
3536

37+
def do_GET(self):
38+
if GitDeploy.is_get_available:
39+
paths = [repository['path'] for repository in self.getConfig()['repositories']]
40+
for path in paths:
41+
self.pull(path)
42+
self.deploy(path)
43+
self.send_response(200)
44+
self.send_header("Content-type", "text/html")
45+
self.end_headers()
46+
self.wfile.write("<html>")
47+
self.wfile.write("<head><title>Github Autodeploy</title></head>")
48+
self.wfile.write("<body><p>Ok, updated.</p></body>")
49+
self.wfile.write("</html>")
50+
else:
51+
self.send_response(500)
52+
3653
def do_POST(self):
3754
event = self.headers.getheader('X-Github-Event')
3855
if event == 'ping':
@@ -109,6 +126,8 @@ def main():
109126
GitDeploy.quiet = True
110127
if arg == '-q' or arg == '--quiet':
111128
GitDeploy.quiet = True
129+
if arg == '-g' or arg == '--get-to-pull':
130+
GitDeploy.is_get_available = True
112131

113132
if GitDeploy.daemon:
114133
pid = os.fork()

0 commit comments

Comments
 (0)