Skip to content

Commit 66fa0ef

Browse files
committed
Update: Adding lambda function to parse github webhooks
1 parent fdb7b0f commit 66fa0ef

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import boto3
2+
3+
def lambda_handler(event, context):
4+
sc = 200
5+
body = "Successfully Triggered a Lambda Function"
6+
7+
#If we want to do the whole organization, something like this:
8+
#if event.repository.owner.login == "rearc":
9+
if event.has_key("repository") and event["repository"]["name"] == "test-lambda-github":
10+
if event["action"] in ["opened", "synchronize"]:
11+
pr = event["pull_request"]
12+
branch = pr["head"]["ref"]
13+
print(branch)
14+
#Figure out what needs to be done so codepipeline uses "branch" to build and trigger a test job?
15+
# Looks like something like this should work:
16+
#codepipeline_client = boto3.client('codepipeline')
17+
#codepipeline_response = codepipeline_client.start_pipeline_execution(
18+
# name="codepipeline-customization-sandbox-pipeline"
19+
#)
20+
else:
21+
body = "Event is not a PR opening or updating"
22+
else:
23+
sc = 400
24+
body = "Request didn't contain a repository key"
25+
26+
return {
27+
'statusCode': sc,
28+
'body': body
29+
}
30+
31+
File renamed without changes.

0 commit comments

Comments
 (0)