From e7b579ed92ac640133e4a7768a37a3ed02f66fb8 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 7 Feb 2017 20:34:24 +0100 Subject: github-lambda: handle multiple records --- src/blogc-github-lambda/lambda_function.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/blogc-github-lambda/lambda_function.py b/src/blogc-github-lambda/lambda_function.py index 8f2d2b3..3511e92 100644 --- a/src/blogc-github-lambda/lambda_function.py +++ b/src/blogc-github-lambda/lambda_function.py @@ -149,11 +149,11 @@ def sync_s3(src, dest, settings_file): remote_files[filename].delete() -def lambda_handler(event, context): - message = event['Records'][0]['Sns']['Message'] +def sns_handler(message): payload = json.loads(message) if payload['ref'] == 'refs/heads/master': + print 'Building: %s' % payload['repository']['full_name'] debug = 'DEBUG' in os.environ env = os.environ.copy() @@ -182,3 +182,11 @@ def lambda_handler(event, context): sync_s3(os.path.join(rootdir, env['OUTPUT_DIR']), payload['repository']['name'], os.path.join(rootdir, 's3.json')) + + else: + print "Commit not for master branch, skipping: %s" % payload['ref'] + +def lambda_handler(event, context): + for record in event['Records']: + if 'Sns' in record: + sns_handler(record['Sns']['Message']) -- cgit v1.2.3-18-g5258