Skip to content

Commit b1ec7a0

Browse files
committed
fix(timestamp): Updated timestamp
1 parent 1eedcaa commit b1ec7a0

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

.github/workflows/unit-tests.yaml

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
name: Update Timestamp
1+
name: Update Commit Timestamp
22

33
on:
44
push:
55
branches:
66
- main
77

88
jobs:
9-
update-timestamp:
9+
update-commit-timestamp:
1010
runs-on: ubuntu-latest
1111

1212
steps:
1313
- name: Checkout repository
1414
uses: actions/checkout@v2
1515

1616
- name: Extract Commit Timestamp
17-
run: echo "$(git log -1 --format=%ci)" > commit_timestamp.txt
18-
19-
- name: Store Timestamp as Environment Variable
20-
run: echo "TIMESTAMP=$(cat commit_timestamp.txt)" >> $GITHUB_ENV
21-
22-
- name: Upload Timestamp as Artifact
23-
uses: actions/upload-artifact@v2
24-
with:
25-
name: commit-timestamp
26-
path: commit_timestamp.txt
17+
run: echo "COMMIT_TIMESTAMP=$(git log -1 --format=%ci)" >> $GITHUB_ENV

pages/api/timestamp.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
3+
export default (req: NextApiRequest, res: NextApiResponse) => {
4+
const timestamp = process.env.TIMESTAMP || 'N/A';
5+
res.status(200).json({ timestamp });
6+
};

src/screens/sandbox/components/sidebar/Sidebar.component.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@ import Button from "@/src/components/Button.component";
33
import Link from "next/link";
44
import { Spacer } from "@/src/components/Components.styles";
55
import { useItems, useServices } from "../../hooks";
6-
import { useEffect } from "react";
6+
import { useEffect, useState } from "react";
77
import ItemList from "./ItemList.component";
88
import { Examples } from "@/src/utils/examples";
99
import Logo from "@/src/components/Logo.component";
1010

1111
export default function Sidebar() {
1212

13+
const [timestamp, setTimestamp] = useState("");
14+
1315
const { storageService, codeService, viewService } = useServices();
1416
const { items } = useItems();
1517

1618
useEffect(() => {
1719
initializeExamples();
1820
}, []);
1921

22+
useEffect(() => {
23+
const timestamp = process.env.COMMIT_TIMESTAMP;
24+
console.log(timestamp);
25+
if (timestamp) {
26+
setTimestamp(timestamp);
27+
}
28+
}, []);
29+
2030
function reset(): void {
2131
codeService.reset();
2232
viewService.set(0);

0 commit comments

Comments
 (0)