feat: add version info endpoint and display in UI
All checks were successful
Build and Push Docker Image / build (push) Successful in 35s

This commit is contained in:
Felix Schlusche
2025-10-24 17:50:21 +02:00
parent 3f36ec3cc7
commit 11c9440806
5 changed files with 44 additions and 1 deletions

View File

@@ -72,7 +72,7 @@ jobs:
with: with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: | tags: |
type=sha,format=short type=sha,format=short,prefix=
type=raw,value=latest,enable={{is_default_branch}} type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image - name: Build and push Docker image
@@ -83,6 +83,9 @@ jobs:
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: |
COMMIT_HASH=${{ github.sha }}
BUILD_DATE=${{ github.event.head_commit.timestamp }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max

View File

@@ -52,6 +52,12 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
ENV NODE_ENV=production \ ENV NODE_ENV=production \
PORT=3000 PORT=3000
# Build arguments for version info
ARG COMMIT_HASH=unknown
ARG BUILD_DATE=unknown
ENV COMMIT_HASH=${COMMIT_HASH}
ENV BUILD_DATE=${BUILD_DATE}
# Use dumb-init to handle signals properly # Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"] ENTRYPOINT ["dumb-init", "--"]

View File

@@ -467,6 +467,7 @@
<i data-lucide="chevron-down" class="w-5 h-5 transition-transform details-chevron"></i> <i data-lucide="chevron-down" class="w-5 h-5 transition-transform details-chevron"></i>
<i data-lucide="settings" class="w-5 h-5 text-purple-400"></i> <i data-lucide="settings" class="w-5 h-5 text-purple-400"></i>
<span>Einstellungen</span> <span>Einstellungen</span>
<span id="versionInfo" class="ml-auto text-xs text-gray-500 font-mono"></span>
</summary> </summary>
<div class="mt-4 flex flex-wrap gap-4 items-center"> <div class="mt-4 flex flex-wrap gap-4 items-center">
<div class="flex-1 min-w-[200px]"> <div class="flex-1 min-w-[200px]">

View File

@@ -2757,6 +2757,27 @@ async function loadSettings() {
} }
} }
/**
* Load and display version info
*/
async function loadVersionInfo() {
try {
const response = await fetch('/api/version');
if (!response.ok) return;
const versionData = await response.json();
const versionEl = document.getElementById('versionInfo');
if (versionEl && versionData.commit) {
const shortHash = versionData.commit.substring(0, 7);
versionEl.textContent = shortHash !== 'dev' ? shortHash : 'dev';
versionEl.title = `Commit: ${versionData.commit}\nBuild: ${versionData.buildDate}`;
}
} catch (error) {
console.log('Could not load version info:', error);
}
}
/** /**
* Handle vacation days input change * Handle vacation days input change
*/ */
@@ -3781,6 +3802,7 @@ document.addEventListener('DOMContentLoaded', async () => {
initializeFlatpickr(); initializeFlatpickr();
initializeEventListeners(); initializeEventListeners();
await loadSettings(); // Load saved settings first await loadSettings(); // Load saved settings first
await loadVersionInfo(); // Load version info
checkRunningTimer(); // Check if timer was running checkRunningTimer(); // Check if timer was running
loadMonthlyView(); // Load monthly view by default loadMonthlyView(); // Load monthly view by default
}); });

View File

@@ -499,6 +499,17 @@ app.get('/api/settings', (req, res) => {
} }
}); });
// Get version/commit info
app.get('/api/version', (req, res) => {
const commitHash = process.env.COMMIT_HASH || 'dev';
const buildDate = process.env.BUILD_DATE || new Date().toISOString();
res.json({
commit: commitHash,
buildDate: buildDate
});
});
// Start server // Start server
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`); console.log(`Server is running on http://localhost:${PORT}`);