Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
building on PR #3 to get a simple multi-builder solution for now
Browse files Browse the repository at this point in the history
  • Loading branch information
duck-rh authored and mscherer committed Jul 20, 2017
1 parent a9c2d96 commit 31d6936
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 24 additions & 5 deletions files/build_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -206,16 +219,17 @@ 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)

if not args.dry_run:
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 '
Expand All @@ -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))
Expand Down
1 change: 1 addition & 0 deletions templates/builder.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: {{ name }}
builder: {{ builder }}
notification:
{% if irc_server %}
irc:
Expand Down

0 comments on commit 31d6936

Please sign in to comment.