Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/deploy-containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ jobs:
digest: ${{ steps.build.outputs.digest }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Compute image prefix
id: meta
run: echo "prefix=${REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"

- name: Compute dashboard version
id: dashboard_version
run: echo "dashboard_version=$(git describe --tags --always)" >> "$GITHUB_OUTPUT"

- name: Log in to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -79,6 +85,8 @@ jobs:
context: .
file: ./dashboard/Dockerfile
push: true
build-args: |
DASHBOARD_VERSION=${{ steps.dashboard_version.outputs.dashboard_version }}
tags: |
${{ steps.meta.outputs.prefix }}/dashboard-frontend:latest
${{ steps.meta.outputs.prefix }}/dashboard-frontend:${{ github.sha }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ jobs:
cp ~/.env-staging dashboard-staging/.env &&
cd dashboard-staging &&
git checkout ${GITHUB_SHA} &&
git fetch --tags --depth 1 || true &&
export DASHBOARD_VERSION=\$(git describe --tags --always) &&
docker compose down &&
docker compose build --no-cache &&
docker compose up -d
Expand Down
3 changes: 3 additions & 0 deletions dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ RUN npm install -g pnpm@10.33.3 && pnpm install --frozen-lockfile

COPY dashboard/. ./

ARG DASHBOARD_VERSION
ENV VITE_APP_VERSION=$DASHBOARD_VERSION

RUN pnpm build

# Stage 2: Copy the static files from the builder stage
Expand Down
24 changes: 24 additions & 0 deletions dashboard/src/components/SideMenu/SideMenuContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/Tooltip';

import { ExternalLinkIcon } from '@/components/Icons/ExternalLink';

import { REPO_URL } from '@/utils/constants/general';

import SendFeedback from './SendFeedback';
import NavLink from './NavLink';
import {
Expand All @@ -25,6 +27,19 @@ import {
type RouteMenuItems,
} from './menuItems';

const versionRepoUrl = (version: string): string => {
if (!version || version === 'unknown' || version.endsWith('-dirty')) {
return REPO_URL;
}

const commitAfterTag = version.match(/-g([0-9a-f]+)$/)?.[1];
if (commitAfterTag) {
return `${REPO_URL}/tree/${commitAfterTag}`;
}

return `${REPO_URL}/tree/${version}`;
};

type SideMenuItemProps = {
item: RouteMenuItems;
};
Expand Down Expand Up @@ -124,6 +139,15 @@ const SideMenuContent = ({
<div className="flex w-full flex-col space-y-0">
{dashboardElements}
</div>
<Separator className="bg-on-secondary-10 my-4" />
<a
href={versionRepoUrl(import.meta.env.VITE_APP_VERSION)}
target="_blank"
rel="noreferrer"
className="block w-full px-4 text-xs break-words text-white/40 hover:text-white/70"
>
{import.meta.env.VITE_APP_VERSION}
</a>
</NavigationMenuList>
</NavigationMenu>
);
Expand Down
15 changes: 15 additions & 0 deletions dashboard/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import path from 'path';
import { execSync } from 'node:child_process';

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import tailwindcss from '@tailwindcss/vite';

import { TanStackRouterVite } from '@tanstack/router-plugin/vite';

const appVersion =
process.env.VITE_APP_VERSION ||
((): string => {
try {
return execSync('git describe --tags --always --dirty').toString().trim();
} catch {
return 'unknown';
}
})();

// https://vitejs.dev/config/
export default defineConfig({
plugins: [tailwindcss(), tsconfigPaths(), react(), TanStackRouterVite()],
define: {
'import.meta.env.VITE_APP_VERSION': JSON.stringify(appVersion),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ services:
build:
context: .
dockerfile: ./dashboard/Dockerfile
args:
DASHBOARD_VERSION: ${DASHBOARD_VERSION:-}
image: ${IMAGE_REGISTRY:-ghcr.io}/${IMAGE_REPOSITORY:-local}/dashboard-frontend:${IMAGE_TAG:-latest}
volumes:
- static-data:/data/static
Expand Down
Loading