Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunnaye committed Apr 15, 2024
1 parent 02f3af1 commit cdd4480
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions upsertGitHubTag/deployment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const http = require("http");
const crypto = require("crypto");
const LAMBDA_USER_AGENT = "DockstoreLambda (NodeJs)";
const DELIVERY_ID_HEADER = "X-GitHub-Delivery";
const client = new S3Client({});

// Verification function to check if it is actually GitHub who is POSTing here
const verifyGitHub = (req, payload) => {
Expand Down Expand Up @@ -253,22 +254,26 @@ function processEvent(event, callback) {
githubEventType +
" from GitHub.",
});
return;
}
// If bucket name is not null (had to put this for the integration test)
if (process.env.BUCKET_NAME) {
// Send payload to s3
const client = new S3Client({});
const uploadDate = new Date();
const repository = body.repository.full_name;
const bucketPath = `${uploadDate.getDay()}-${uploadDate.getMonth()}-${uploadDate.getFullYear()}/${repository}/${deliveryId}` //formats path to DD-MM-YYYY/repository/deliveryid

Check failure on line 264 in upsertGitHubTag/deployment/index.js

View workflow job for this annotation

GitHub Actions / linterWithESLint

Insert `;`

Check failure on line 264 in upsertGitHubTag/deployment/index.js

View workflow job for this annotation

GitHub Actions / linterWithESLint

Insert `;`

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (98% of all statements in
the enclosing function
have an explicit semicolon).

const command = new PutObjectCommand({
Bucket: process.env.BUCKET_NAME,
Key: deliveryId,
Key: bucketPath,
Body: JSON.stringify(body),
ContentType: "application/json",
});
try {
const response = client.send(command);
console.log(response);
console.log("Successfully uploaded payload to bucket", response);
} catch (err) {
console.error(err);
console.error("Error uploading payload to bucket", err);
}
}
}
Expand Down

0 comments on commit cdd4480

Please sign in to comment.