diff --git a/defaults/main.yml b/defaults/main.yml index 6a0c55b..f2c1188 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,7 @@ # the username that will run the middleman builder # # user will be created along a pair of ssh key builder_username: middleman_builder +builder: 'middleman' update_submodules: True watchers: [] irc_server: False diff --git a/files/build_deploy.py b/files/build_deploy.py index 63b0dc5..04910de 100644 --- a/files/build_deploy.py +++ b/files/build_deploy.py @@ -49,6 +49,19 @@ args = parser.parse_args() +builder_info = { + 'middleman': { + 'build_command': ['bundle', 'exec', 'middleman', 'build', '--verbose'], + 'build_subdir': 'build', + 'deploy_command': ['bundle', 'exec', 'middleman', 'deploy'] + }, + 'jekyll': { + 'build_command': ['bundle', 'exec', 'jekyll', 'build', '--incremental', '--verbose', '--trace'], + 'build_subdir': '_site', + 'deploy_command': None + } +} + def debug_print(message): if args.debug: print message @@ -206,9 +219,9 @@ def notify_error(stage, error): notify_error('install', C.output) try: - syslog.syslog("Build of {}: bundle exec middleman build".format(name)) - result = subprocess.check_output(['bundle', 'exec', 'middleman', - 'build', '--verbose']) + command = builder_info[config['builder']]['build_command'] + syslog.syslog("Build of {}: {}".format(name, ' '.join(command))) + result = subprocess.check_output(command) except subprocess.CalledProcessError, C: notify_error('build', C.output) @@ -216,6 +229,7 @@ def notify_error(stage, error): syslog.syslog("Build of {}: start sync".format(name)) # TODO log the message if config['remote']: + build_subdir = builder_info[config['builder']]['build_subdir'] subprocess.call(['rsync', '-e', 'ssh ' @@ -227,9 +241,14 @@ def notify_error(stage, error): os.path.expanduser('~/.ssh/{}_id.rsa'.format(name)), '--delete-after', '-rqavz', - '%s/build/' % checkout_dir, config['remote']]) + '%s/%s/' % (checkout_dir, build_subdir), + config['remote']]) else: - subprocess.call(['bundle', 'exec', 'middleman', 'deploy']) + command = builder_info[config['builder']]['deploy_command'] + if command: + subprocess.call(command) + else: + notify_error('deploy', "builder '%s' does not possess a deploy method" % config['builder']) syslog.syslog("Build of {}: finish sync".format(name)) else: syslog.syslog("Build of {}: not syncing, dry-run".format(name)) diff --git a/templates/builder.yml b/templates/builder.yml index 57c5b16..6b212ad 100644 --- a/templates/builder.yml +++ b/templates/builder.yml @@ -1,4 +1,5 @@ name: {{ name }} +builder: {{ builder }} notification: {% if irc_server %} irc: