Skip to content

Commit 759b6a0

Browse files
committed
add eventtype
1 parent a9df2b9 commit 759b6a0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

upsertGitHubTag/deployment/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function processEvent(event, callback) {
171171
// The installation_repositories event contains information about both additions and removals.
172172
console.log("Valid installation event");
173173

174-
logPayloadToS3(body, deliveryId); //upload event to S3
174+
logPayloadToS3(githubEventType, body, deliveryId); //upload event to S3
175175

176176
path += "workflows/github/install";
177177
postEndpoint(path, body, deliveryId, (response) => {
@@ -207,7 +207,7 @@ function processEvent(event, callback) {
207207
// A push has been made for some repository (ignore pushes that are deletes)
208208
if (!body.deleted) {
209209
console.log("Valid push event");
210-
logPayloadToS3(body, deliveryId); //upload event to S3
210+
logPayloadToS3(githubEventType, body, deliveryId); //upload event to S3
211211

212212
const repository = body.repository.full_name;
213213
const gitReference = body.ref;
@@ -225,6 +225,7 @@ function processEvent(event, callback) {
225225
});
226226
} else {
227227
console.log("Valid push event (delete)");
228+
logPayloadToS3(githubEventType, body, deliveryId); //upload event to S3
228229
const repository = body.repository.full_name;
229230
const gitReference = body.ref;
230231
const username = body.sender.login;
@@ -263,7 +264,7 @@ function processEvent(event, callback) {
263264
}
264265
}
265266

266-
function logPayloadToS3(body, deliveryId) {
267+
function logPayloadToS3(eventType, body, deliveryId) {
267268
// If bucket name is not null (had to put this for the integration test)
268269
if (process.env.BUCKET_NAME) {
269270
const date = new Date();
@@ -273,10 +274,14 @@ function logPayloadToS3(body, deliveryId) {
273274
const uploadHour = date.getHours().toString().padStart(2, "0"); // ex. get 05 instead of 5 for the 5th hour
274275
const bucketPath = `${uploadYear}-${uploadMonth}-${uploadDate}/${uploadHour}/${deliveryId}`;
275276

277+
const fullPayload = {}
278+
fullPayload[eventType] = eventType;
279+
fullPayload[body] = body;
280+
276281
const command = new PutObjectCommand({
277282
Bucket: process.env.BUCKET_NAME,
278283
Key: bucketPath,
279-
Body: JSON.stringify(body),
284+
Body: JSON.stringify(fullPayload),
280285
ContentType: "application/json",
281286
});
282287
try {

0 commit comments

Comments
 (0)