diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-12-27 04:18:39 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-12-27 04:18:39 +0100 |
commit | a913539c26ec3f34bbdf9474b77d528451b2042a (patch) | |
tree | 049183e370fd6cd179d09cddeb661f357ff89348 /src/blogc-github-lambda/lambda_function.py | |
parent | 879e295de04bc0699462c959a1d331dcf5446345 (diff) | |
download | blogc-a913539c26ec3f34bbdf9474b77d528451b2042a.tar.gz blogc-a913539c26ec3f34bbdf9474b77d528451b2042a.tar.bz2 blogc-a913539c26ec3f34bbdf9474b77d528451b2042a.zip |
github-lambda: blogc-make: integrate
Diffstat (limited to 'src/blogc-github-lambda/lambda_function.py')
-rw-r--r-- | src/blogc-github-lambda/lambda_function.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/blogc-github-lambda/lambda_function.py b/src/blogc-github-lambda/lambda_function.py index 44f1bc9..b845285 100644 --- a/src/blogc-github-lambda/lambda_function.py +++ b/src/blogc-github-lambda/lambda_function.py @@ -142,16 +142,30 @@ def lambda_handler(event, context): if payload['ref'] == 'refs/heads/master': debug = 'DEBUG' in os.environ - stream = None if debug else subprocess.PIPE + + env = os.environ.copy() + env['BLOGC'] = os.path.join(cwd, 'blogc') + env['OUTPUT_DIR'] = '_build_lambda' rootdir = get_tarball(payload['repository']['full_name']) - rv = subprocess.call(['make', '-C', rootdir, - 'BLOGC=%s' % os.path.join(cwd, 'blogc'), - 'OUTPUT_DIR=_build'], - stdout=stream, stderr=stream) + settings_file = os.path.join(rootdir, 'settings.ini') + + if os.path.isfile(settings_file): + # deploy using blogc-make + args = [os.path.join(cwd, 'blogc'), '-m', '-f', settings_file, + 'all'] + if debug: + args.append('-V') + rv = subprocess.call(args, env=env) + else: + # fallback to using make. please note that this will break if + # amazon removes gnu make from lambda images + stream = None if debug else subprocess.PIPE + rv = subprocess.call(['make', '-C', rootdir], env=env, + stdout=stream, stderr=stream) if rv != 0: - raise RuntimeError('Failed to run make') + raise RuntimeError('Failed to run the build tool.') - sync_s3(os.path.join(rootdir, '_build'), + sync_s3(os.path.join(rootdir, env['OUTPUT_DIR']), payload['repository']['name'], os.path.join(rootdir, 's3.json')) |