From a9327d28853af44b49a307104179527316a486f1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 23 Dec 2024 20:54:10 +0800 Subject: [PATCH] Add commit hash to client sidebar --- .github/workflows/docker-staging.yml | 1 + .github/workflows/docker.yml | 3 ++- client/Dockerfile | 3 +++ client/src/components/sidebar/Sidebar.tsx | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-staging.yml b/.github/workflows/docker-staging.yml index 7cb2cb295..7ecfb7e16 100644 --- a/.github/workflows/docker-staging.yml +++ b/.github/workflows/docker-staging.yml @@ -42,6 +42,7 @@ jobs: GOOGLE_OAUTH_CLIENT_ID=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }} SENTRY_INGEST_CLIENT=${{ secrets.SENTRY_INGEST_CLIENT }} SENTRY_TRACE_RATE_CLIENT=${{ secrets.SENTRY_TRACE_RATE_CLIENT }} + GIT_COMMIT=${{ github.sha }} tags: | ghcr.io/csesoc/notangles-client:${{ github.sha }} ghcr.io/csesoc/notangles-client:latest diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3d0c90bc6..077b18c2a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -42,6 +42,7 @@ jobs: GOOGLE_OAUTH_CLIENT_ID=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }} SENTRY_INGEST_CLIENT=${{ secrets.SENTRY_INGEST_CLIENT }} SENTRY_TRACE_RATE_CLIENT=${{ secrets.SENTRY_TRACE_RATE_CLIENT }} + GIT_COMMIT=${{ github.sha }} tags: | ghcr.io/csesoc/notangles-client:${{ github.sha }} ghcr.io/csesoc/notangles-client:latest @@ -122,4 +123,4 @@ jobs: git commit -m "feat(notangles): update images" git push -u origin update/notangles/${{ github.sha }} gh pr create -B migration --title "feat(notangles): update images" --body "Updates the images for the notangles deployment to commit csesoc/notangles@${{ github.sha }}." > URL - gh pr merge $(cat URL) --squash -d \ No newline at end of file + gh pr merge $(cat URL) --squash -d diff --git a/client/Dockerfile b/client/Dockerfile index 7858d7770..4973ea131 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -27,6 +27,9 @@ ENV VITE_APP_SENTRY_TRACE_RATE_CLIENT=$SENTRY_TRACE_RATE_CLIENT ENV VITE_APP_ENVIRONMENT=production ENV NODE_ENV=production +ARG GIT_COMMIT +RUN if [ -n "$GIT_COMMIT" ]; then export VITE_COMMIT=$GIT_COMMIT; fi + RUN pnpm run build FROM caddy:2.8.4-alpine diff --git a/client/src/components/sidebar/Sidebar.tsx b/client/src/components/sidebar/Sidebar.tsx index 13fdd06ff..d6f56600b 100644 --- a/client/src/components/sidebar/Sidebar.tsx +++ b/client/src/components/sidebar/Sidebar.tsx @@ -248,7 +248,7 @@ const Sidebar: React.FC = () => { {!collapsed ? ( - © DevSoc {new Date().getFullYear()}, v1.0.0 + {import.meta.env.VITE_COMMIT?.substring(0, 7) ?? 'unknown commit'} ) : ( handleCollapse(false)} toolTipTitle="Expand" />