From 65623ce0ebffaf0afb7f423bce8d4d545dd0bcc7 Mon Sep 17 00:00:00 2001 From: nmemmert Date: Thu, 17 Sep 2026 16:52:44 -0400 Subject: [PATCH] Wire up deployment metadata: build commit, number, and server start time; v2.0.30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: expose BUILD_COMMIT and BUILD_NUMBER env vars from build args (was COMMIT_SHA only; server was reading BUILD_COMMIT so it always fell through to null) - CI: pass github.run_number as BUILD_NUMBER build arg - state.js: record serverStartedAt at module load so deployedAt always shows when the current container instance came up, even without an env var - admin-content.js: fall back COMMIT_SHA → BUILD_COMMIT for older images, use state.serverStartedAt when DEPLOYED_AT env var not set Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/docker-publish.yml | 1 + Dockerfile | 4 +++- package.json | 2 +- server/routes/admin-content.js | 4 ++-- server/state.js | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index eae38f9..8b93b6e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -63,3 +63,4 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | COMMIT_SHA=${{ github.sha }} + BUILD_NUMBER=${{ github.run_number }} diff --git a/Dockerfile b/Dockerfile index 111acbf..ae01a7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,9 @@ ENV NODE_ENV=production ENV PORT=4173 ARG COMMIT_SHA=unknown -ENV COMMIT_SHA=${COMMIT_SHA} +ARG BUILD_NUMBER=unknown +ENV BUILD_COMMIT=${COMMIT_SHA} +ENV BUILD_NUMBER=${BUILD_NUMBER} COPY --from=deps /app/node_modules ./node_modules diff --git a/package.json b/package.json index c22aca9..55502cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "siteforge", "private": true, - "version": "2.0.29", + "version": "2.0.30", "type": "module", "scripts": { "dev": "vite", diff --git a/server/routes/admin-content.js b/server/routes/admin-content.js index fa4cc3d..c3166fa 100644 --- a/server/routes/admin-content.js +++ b/server/routes/admin-content.js @@ -227,9 +227,9 @@ export function register(app) { app.get('/api/admin-ops/status', requireAdminAuth, (_req, res) => { res.json({ - buildCommit: process.env.BUILD_COMMIT ?? null, + buildCommit: process.env.BUILD_COMMIT ?? process.env.COMMIT_SHA ?? null, buildNumber: process.env.BUILD_NUMBER ?? null, - deployedAt: process.env.DEPLOYED_AT ?? null, + deployedAt: process.env.DEPLOYED_AT ?? state.serverStartedAt, cachePurge: state.lastCachePurgeStatus, deployHook: state.lastDeployHookStatus, }) diff --git a/server/state.js b/server/state.js index 1c895da..9f6df1b 100644 --- a/server/state.js +++ b/server/state.js @@ -7,6 +7,8 @@ import { } from './config.js' export const state = { + serverStartedAt: new Date().toISOString(), + cachedSiteContent: null, cachedDraftSiteContent: null, publishState: { ...DEFAULT_PUBLISH_STATE },