diff options
Diffstat (limited to 'gitautodeploy')
-rwxr-xr-x | gitautodeploy/data/git-auto-deploy.conf.json | 34 | ||||
-rw-r--r-- | gitautodeploy/gitautodeploy.py | 20 | ||||
-rw-r--r-- | gitautodeploy/httpserver.py | 3 |
3 files changed, 55 insertions, 2 deletions
diff --git a/gitautodeploy/data/git-auto-deploy.conf.json b/gitautodeploy/data/git-auto-deploy.conf.json new file mode 100755 index 0000000..e8ab9d1 --- /dev/null +++ b/gitautodeploy/data/git-auto-deploy.conf.json @@ -0,0 +1,34 @@ +{ +// "pidfilepath": "/var/run/git-auto-deploy/git-auto-deploy.pid", + "logfilepath": "/var/log/git-auto-deploy.log", + "host": "0.0.0.0", + "port": 8001, + "global_deploy": [ + "echo Deploy started!", + "echo Deploy completed!" + ], + "repositories": [ + { + "url": "https://github.com/olipo186/Git-Auto-Deploy.git", + "branch": "master", + "remote": "origin", + "path": "/var/lib/git-auto-deploy/Git-Auto-Deploy", + "deploy": "echo deploying" + }, + { + "url": "https://github.com/github/gitignore", + "path": "/var/lib/git-auto-deploy/gitignore" + } +// ,{ +// "url": "https://api.github.com/repos/olipo186/Git-Auto-Deploy", +// "deploy": "echo deploying after pull request", +// "filters": [ +// { +// "type": "pull-request-filter", +// "action": "closed", +// "ref": "testing-branch" +// } +// ] +// } + ] +}
\ No newline at end of file diff --git a/gitautodeploy/gitautodeploy.py b/gitautodeploy/gitautodeploy.py index a618d40..6b238c5 100644 --- a/gitautodeploy/gitautodeploy.py +++ b/gitautodeploy/gitautodeploy.py @@ -375,6 +375,8 @@ class GitAutoDeploy(object): default_config_value = 'GAD_CONFIG' in os.environ and os.environ['GAD_CONFIG'] or None default_ssh_keygen_value = 'GAD_SSH_KEYGEN' in os.environ or False default_force_value = 'GAD_FORCE' in os.environ or False + default_use_ssl = 'GAD_SSL' in os.environ or False + default_ssl_pem_file_path = 'GAD_SSL_PEM_FILE' in os.environ and os.environ['GAD_SSL_PEM_FILE'] or '~/.gitautodeploy.pem' default_pid_file_value = 'GAD_PID_FILE' in os.environ and os.environ['GAD_PID_FILE'] or '~/.gitautodeploy.pid' default_log_file_value = 'GAD_LOG_FILE' in os.environ and os.environ['GAD_LOG_FILE'] or None default_host_value = 'GAD_HOST' in os.environ and os.environ['GAD_HOST'] or '0.0.0.0' @@ -427,6 +429,16 @@ class GitAutoDeploy(object): default=default_port_value, type=int) + parser.add_argument("--ssl", + help="use ssl", + default=default_use_ssl, + action="store_true") + + parser.add_argument("--ssl-pem", + help="path to ssl pem file", + default=default_ssl_pem_file_path, + type=str) + args = parser.parse_args() # Set up logging @@ -503,7 +515,7 @@ class GitAutoDeploy(object): # to file and console depending on user preference) sys.stdout = LogInterface(logger.info) sys.stderr = LogInterface(logger.error) - + if args.daemon_mode: logger.info('Starting Git Auto Deploy in daemon mode') GitAutoDeploy.create_daemon() @@ -525,6 +537,12 @@ class GitAutoDeploy(object): self._server = HTTPServer((self._config['host'], self._config['port']), WebhookRequestHandler) + if args.ssl: + import ssl + logger.info("enabling ssl") + self._server.socket = ssl.wrap_socket(self._server.socket, + certfile=os.path.expanduser(args.ssl_pem), + server_side=True) sa = self._server.socket.getsockname() logger.info("Listening on %s port %s", sa[0], sa[1]) self._server.serve_forever() diff --git a/gitautodeploy/httpserver.py b/gitautodeploy/httpserver.py index 0760067..99fc574 100644 --- a/gitautodeploy/httpserver.py +++ b/gitautodeploy/httpserver.py @@ -118,6 +118,7 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): import logging from wrappers import GitWrapper from lock import Lock + import json logger = logging.getLogger() data = json.loads(request_body) @@ -190,4 +191,4 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): # Release the lock if it's ours if waiting_lock.has_lock(): - waiting_lock.release()
\ No newline at end of file + waiting_lock.release() |