From 759b6a08506490e6d0d0c44ab6b1a8f3b981d47f Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Wed, 10 Jul 2024 11:27:46 -0400 Subject: [PATCH 1/3] add eventtype --- upsertGitHubTag/deployment/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/upsertGitHubTag/deployment/index.js b/upsertGitHubTag/deployment/index.js index 027df9b..e6d1f8b 100644 --- a/upsertGitHubTag/deployment/index.js +++ b/upsertGitHubTag/deployment/index.js @@ -171,7 +171,7 @@ function processEvent(event, callback) { // The installation_repositories event contains information about both additions and removals. console.log("Valid installation event"); - logPayloadToS3(body, deliveryId); //upload event to S3 + logPayloadToS3(githubEventType, body, deliveryId); //upload event to S3 path += "workflows/github/install"; postEndpoint(path, body, deliveryId, (response) => { @@ -207,7 +207,7 @@ function processEvent(event, callback) { // A push has been made for some repository (ignore pushes that are deletes) if (!body.deleted) { console.log("Valid push event"); - logPayloadToS3(body, deliveryId); //upload event to S3 + logPayloadToS3(githubEventType, body, deliveryId); //upload event to S3 const repository = body.repository.full_name; const gitReference = body.ref; @@ -225,6 +225,7 @@ function processEvent(event, callback) { }); } else { console.log("Valid push event (delete)"); + logPayloadToS3(githubEventType, body, deliveryId); //upload event to S3 const repository = body.repository.full_name; const gitReference = body.ref; const username = body.sender.login; @@ -263,7 +264,7 @@ function processEvent(event, callback) { } } -function logPayloadToS3(body, deliveryId) { +function logPayloadToS3(eventType, body, deliveryId) { // If bucket name is not null (had to put this for the integration test) if (process.env.BUCKET_NAME) { const date = new Date(); @@ -273,10 +274,14 @@ function logPayloadToS3(body, deliveryId) { const uploadHour = date.getHours().toString().padStart(2, "0"); // ex. get 05 instead of 5 for the 5th hour const bucketPath = `${uploadYear}-${uploadMonth}-${uploadDate}/${uploadHour}/${deliveryId}`; + const fullPayload = {} + fullPayload[eventType] = eventType; + fullPayload[body] = body; + const command = new PutObjectCommand({ Bucket: process.env.BUCKET_NAME, Key: bucketPath, - Body: JSON.stringify(body), + Body: JSON.stringify(fullPayload), ContentType: "application/json", }); try { From fede33a8ea895642e09fe9837d3ac03521a66ef2 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Wed, 10 Jul 2024 11:33:23 -0400 Subject: [PATCH 2/3] lint --- upsertGitHubTag/deployment/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upsertGitHubTag/deployment/index.js b/upsertGitHubTag/deployment/index.js index e6d1f8b..efb45fd 100644 --- a/upsertGitHubTag/deployment/index.js +++ b/upsertGitHubTag/deployment/index.js @@ -274,7 +274,7 @@ function logPayloadToS3(eventType, body, deliveryId) { const uploadHour = date.getHours().toString().padStart(2, "0"); // ex. get 05 instead of 5 for the 5th hour const bucketPath = `${uploadYear}-${uploadMonth}-${uploadDate}/${uploadHour}/${deliveryId}`; - const fullPayload = {} + const fullPayload = {}; fullPayload[eventType] = eventType; fullPayload[body] = body; From ab134c095bd690c336be8bc58115e0fc92d1ef46 Mon Sep 17 00:00:00 2001 From: hyunnaye Date: Wed, 10 Jul 2024 16:46:21 -0400 Subject: [PATCH 3/3] oops --- upsertGitHubTag/deployment/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upsertGitHubTag/deployment/index.js b/upsertGitHubTag/deployment/index.js index efb45fd..b722d00 100644 --- a/upsertGitHubTag/deployment/index.js +++ b/upsertGitHubTag/deployment/index.js @@ -275,8 +275,8 @@ function logPayloadToS3(eventType, body, deliveryId) { const bucketPath = `${uploadYear}-${uploadMonth}-${uploadDate}/${uploadHour}/${deliveryId}`; const fullPayload = {}; - fullPayload[eventType] = eventType; - fullPayload[body] = body; + fullPayload["eventType"] = eventType; + fullPayload["body"] = body; const command = new PutObjectCommand({ Bucket: process.env.BUCKET_NAME,