feat: add version info endpoint and display in UI
All checks were successful
Build and Push Docker Image / build (push) Successful in 35s
All checks were successful
Build and Push Docker Image / build (push) Successful in 35s
This commit is contained in:
@@ -72,7 +72,7 @@ jobs:
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=sha,format=short
|
||||
type=sha,format=short,prefix=
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
@@ -83,6 +83,9 @@ jobs:
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
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-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||
|
||||
|
||||
@@ -52,6 +52,12 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
ENV NODE_ENV=production \
|
||||
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
|
||||
ENTRYPOINT ["dumb-init", "--"]
|
||||
|
||||
|
||||
@@ -467,6 +467,7 @@
|
||||
<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>
|
||||
<span>Einstellungen</span>
|
||||
<span id="versionInfo" class="ml-auto text-xs text-gray-500 font-mono"></span>
|
||||
</summary>
|
||||
<div class="mt-4 flex flex-wrap gap-4 items-center">
|
||||
<div class="flex-1 min-w-[200px]">
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -3781,6 +3802,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
initializeFlatpickr();
|
||||
initializeEventListeners();
|
||||
await loadSettings(); // Load saved settings first
|
||||
await loadVersionInfo(); // Load version info
|
||||
checkRunningTimer(); // Check if timer was running
|
||||
loadMonthlyView(); // Load monthly view by default
|
||||
});
|
||||
|
||||
11
server.js
11
server.js
@@ -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
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on http://localhost:${PORT}`);
|
||||
|
||||
Reference in New Issue
Block a user