Skip to content

Commit 1b83dcc

Browse files
authored
Added timestamp to raw event json (#29)
Signed-off-by: Brandon Shien <bshien@amazon.com>
1 parent b3ea737 commit 1b83dcc

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opensearch-automation-app",
3-
"version": "0.1.12",
3+
"version": "0.1.13",
44
"description": "An Automation App that handles all your GitHub Repository Activities",
55
"author": "Peter Zhu",
66
"homepage": "https://github.com/opensearch-project/automation-app",

src/call/github-events-to-s3.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export default async function githubEventsToS3(app: Probot, context: any, resour
2121
const repoName = context.payload.repository?.name;
2222
const eventName = context.payload.action === undefined ? context.name : `${context.name}.${context.payload.action}`;
2323

24+
context.uploaded_at = new Date().toISOString();
25+
2426
const now = new Date();
2527
const [day, month, year] = [now.getDate(), now.getMonth() + 1, now.getFullYear()].map((num) => String(num).padStart(2, '0'));
2628

test/call/github-events-to-s3.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ describe('githubEventsToS3', () => {
9090
jest.spyOn(Date.prototype, 'getDate').mockReturnValue(4);
9191
jest.spyOn(Date.prototype, 'getMonth').mockReturnValue(8);
9292
jest.spyOn(Date.prototype, 'getFullYear').mockReturnValue(2024);
93+
jest.spyOn(Date.prototype, 'toISOString').mockReturnValue('2024-10-04T21:00:06.875Z');
9394

9495
await githubEventsToS3(app, context, resource);
9596

9697
expect(PutObjectCommand).toHaveBeenCalledWith(
9798
expect.objectContaining({
99+
Body: expect.stringMatching('"uploaded_at":"2024-10-04T21:00:06.875Z"'),
98100
Key: expect.stringMatching(`name.action/2024-09-04/repo-id`),
99101
}),
100102
);
@@ -115,11 +117,13 @@ describe('githubEventsToS3', () => {
115117
jest.spyOn(Date.prototype, 'getDate').mockReturnValue(4);
116118
jest.spyOn(Date.prototype, 'getMonth').mockReturnValue(8);
117119
jest.spyOn(Date.prototype, 'getFullYear').mockReturnValue(2024);
120+
jest.spyOn(Date.prototype, 'toISOString').mockReturnValue('2024-10-04T21:00:06.875Z');
118121

119122
await githubEventsToS3(app, context, resource);
120123

121124
expect(PutObjectCommand).toHaveBeenCalledWith(
122125
expect.objectContaining({
126+
Body: expect.stringMatching('"uploaded_at":"2024-10-04T21:00:06.875Z"'),
123127
Key: expect.stringMatching(`name/2024-09-04/repo-id`),
124128
}),
125129
);

0 commit comments

Comments
 (0)