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

Commit 31d6936

Browse files
duck-rhmscherer
authored andcommitted
building on PR #3 to get a simple multi-builder solution for now
1 parent a9c2d96 commit 31d6936

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# the username that will run the middleman builder
22
# # user will be created along a pair of ssh key
33
builder_username: middleman_builder
4+
builder: 'middleman'
45
update_submodules: True
56
watchers: []
67
irc_server: False

files/build_deploy.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@
4949
args = parser.parse_args()
5050

5151

52+
builder_info = {
53+
'middleman': {
54+
'build_command': ['bundle', 'exec', 'middleman', 'build', '--verbose'],
55+
'build_subdir': 'build',
56+
'deploy_command': ['bundle', 'exec', 'middleman', 'deploy']
57+
},
58+
'jekyll': {
59+
'build_command': ['bundle', 'exec', 'jekyll', 'build', '--incremental', '--verbose', '--trace'],
60+
'build_subdir': '_site',
61+
'deploy_command': None
62+
}
63+
}
64+
5265
def debug_print(message):
5366
if args.debug:
5467
print message
@@ -206,16 +219,17 @@ def notify_error(stage, error):
206219
notify_error('install', C.output)
207220

208221
try:
209-
syslog.syslog("Build of {}: bundle exec middleman build".format(name))
210-
result = subprocess.check_output(['bundle', 'exec', 'middleman',
211-
'build', '--verbose'])
222+
command = builder_info[config['builder']]['build_command']
223+
syslog.syslog("Build of {}: {}".format(name, ' '.join(command)))
224+
result = subprocess.check_output(command)
212225
except subprocess.CalledProcessError, C:
213226
notify_error('build', C.output)
214227

215228
if not args.dry_run:
216229
syslog.syslog("Build of {}: start sync".format(name))
217230
# TODO log the message
218231
if config['remote']:
232+
build_subdir = builder_info[config['builder']]['build_subdir']
219233
subprocess.call(['rsync',
220234
'-e',
221235
'ssh '
@@ -227,9 +241,14 @@ def notify_error(stage, error):
227241
os.path.expanduser('~/.ssh/{}_id.rsa'.format(name)),
228242
'--delete-after',
229243
'-rqavz',
230-
'%s/build/' % checkout_dir, config['remote']])
244+
'%s/%s/' % (checkout_dir, build_subdir),
245+
config['remote']])
231246
else:
232-
subprocess.call(['bundle', 'exec', 'middleman', 'deploy'])
247+
command = builder_info[config['builder']]['deploy_command']
248+
if command:
249+
subprocess.call(command)
250+
else:
251+
notify_error('deploy', "builder '%s' does not possess a deploy method" % config['builder'])
233252
syslog.syslog("Build of {}: finish sync".format(name))
234253
else:
235254
syslog.syslog("Build of {}: not syncing, dry-run".format(name))

templates/builder.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: {{ name }}
2+
builder: {{ builder }}
23
notification:
34
{% if irc_server %}
45
irc:

0 commit comments

Comments
 (0)