Skip to content

Commit

Permalink
fix(timestamp): Updated timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasBoda committed Feb 20, 2024
1 parent 1eedcaa commit b1ec7a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
name: Update Timestamp
name: Update Commit Timestamp

on:
push:
branches:
- main

jobs:
update-timestamp:
update-commit-timestamp:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Extract Commit Timestamp
run: echo "$(git log -1 --format=%ci)" > commit_timestamp.txt

- name: Store Timestamp as Environment Variable
run: echo "TIMESTAMP=$(cat commit_timestamp.txt)" >> $GITHUB_ENV

- name: Upload Timestamp as Artifact
uses: actions/upload-artifact@v2
with:
name: commit-timestamp
path: commit_timestamp.txt
run: echo "COMMIT_TIMESTAMP=$(git log -1 --format=%ci)" >> $GITHUB_ENV
6 changes: 6 additions & 0 deletions pages/api/timestamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next';

export default (req: NextApiRequest, res: NextApiResponse) => {
const timestamp = process.env.TIMESTAMP || 'N/A';
res.status(200).json({ timestamp });
};
12 changes: 11 additions & 1 deletion src/screens/sandbox/components/sidebar/Sidebar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ import Button from "@/src/components/Button.component";
import Link from "next/link";
import { Spacer } from "@/src/components/Components.styles";
import { useItems, useServices } from "../../hooks";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import ItemList from "./ItemList.component";
import { Examples } from "@/src/utils/examples";
import Logo from "@/src/components/Logo.component";

export default function Sidebar() {

const [timestamp, setTimestamp] = useState("");

const { storageService, codeService, viewService } = useServices();
const { items } = useItems();

useEffect(() => {
initializeExamples();
}, []);

useEffect(() => {
const timestamp = process.env.COMMIT_TIMESTAMP;
console.log(timestamp);
if (timestamp) {
setTimestamp(timestamp);
}
}, []);

function reset(): void {
codeService.reset();
viewService.set(0);
Expand Down

0 comments on commit b1ec7a0

Please sign in to comment.