aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-github-lambda/lambda_function.py
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2017-02-07 20:34:24 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2017-02-07 20:34:24 +0100
commite7b579ed92ac640133e4a7768a37a3ed02f66fb8 (patch)
tree6b0055c15387a2c5b922911bd5552bd097547f3b /src/blogc-github-lambda/lambda_function.py
parent665a2207f1de24bb9dffad2630d88157fa34e9e2 (diff)
downloadblogc-e7b579ed92ac640133e4a7768a37a3ed02f66fb8.tar.gz
blogc-e7b579ed92ac640133e4a7768a37a3ed02f66fb8.tar.bz2
blogc-e7b579ed92ac640133e4a7768a37a3ed02f66fb8.zip
github-lambda: handle multiple records
Diffstat (limited to 'src/blogc-github-lambda/lambda_function.py')
-rw-r--r--src/blogc-github-lambda/lambda_function.py12
1 files 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'])