Skip to content

Commit c35458f

Browse files
rajbosCopilot
andcommitted
feat(sharing-server): add deployment footer with SHA, branch, and build date
- Inject DEPLOY_SHA, DEPLOY_BRANCH, DEPLOY_DATE as Docker build args into the runtime stage ENV so the running container knows its own version - Add a subtle footer to every page in the layout() function showing: deployed from <branch> · <short sha> · <build date> - Expose version info in the /health endpoint (no login required) - Pass build-args in the deploy workflow (sha, branch, build date) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent da3edb4 commit c35458f

4 files changed

Lines changed: 38 additions & 2 deletions

File tree

.github/workflows/sharing-server-deploy.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ jobs:
114114
type=sha,prefix=sha-,format=long
115115
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
116116
117+
- name: Set build metadata
118+
id: build-meta
119+
run: |
120+
echo "date=$(date -u +'%Y-%m-%d %H:%M UTC')" >> "$GITHUB_OUTPUT"
121+
117122
- name: Build and push
118123
id: build
119124
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
@@ -124,6 +129,10 @@ jobs:
124129
labels: ${{ steps.meta.outputs.labels }}
125130
cache-from: type=gha
126131
cache-to: type=gha,mode=max
132+
build-args: |
133+
DEPLOY_SHA=${{ github.sha }}
134+
DEPLOY_BRANCH=${{ github.ref_name }}
135+
DEPLOY_DATE=${{ steps.build-meta.outputs.date }}
127136
128137
- name: Set image output (digest-pinned reference)
129138
id: image-ref

sharing-server/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ VOLUME ["/data"]
3030

3131
EXPOSE 3000
3232

33+
ARG DEPLOY_SHA=unknown
34+
ARG DEPLOY_BRANCH=unknown
35+
ARG DEPLOY_DATE=unknown
36+
3337
ENV NODE_ENV=production \
3438
DATA_DIR=/data \
35-
PORT=3000
39+
PORT=3000 \
40+
DEPLOY_SHA=$DEPLOY_SHA \
41+
DEPLOY_BRANCH=$DEPLOY_BRANCH \
42+
DEPLOY_DATE=$DEPLOY_DATE
3643

3744
# Use tini as PID 1 for proper signal handling
3845
ENTRYPOINT ["tini", "--"]

sharing-server/src/routes/dashboard.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID ?? '';
1717
const GITHUB_CLIENT_SECRET = process.env.GITHUB_CLIENT_SECRET ?? '';
1818
const BASE_URL = (process.env.BASE_URL ?? 'http://localhost:3000').replace(/\/$/, '');
1919

20+
const DEPLOY_SHA = process.env.DEPLOY_SHA ?? 'unknown';
21+
const DEPLOY_BRANCH = process.env.DEPLOY_BRANCH ?? 'unknown';
22+
const DEPLOY_DATE = process.env.DEPLOY_DATE ?? 'unknown';
23+
2024
// Load Chart.js UMD bundle once at startup — copied to dist/ by esbuild.js
2125
// eslint-disable-next-line @typescript-eslint/no-require-imports
2226
const _chartJsCode: string = (() => {
@@ -403,10 +407,18 @@ function layout(title: string, body: string): string {
403407
.btn-secondary { background: #21262d; color: #c9d1d9; border: 1px solid #30363d; }
404408
.btn-secondary:hover { background: #30363d; }
405409
code { background: #21262d; border-radius: 4px; padding: 1px 5px; font-size: 0.875em; }
410+
411+
/* ── Footer ── */
412+
.deploy-footer { text-align: center; padding: 20px; margin-top: 8px;
413+
color: #484f58; font-size: 0.75rem; border-top: 1px solid #21262d; }
414+
.deploy-footer code { background: transparent; color: #484f58; padding: 0; font-size: 0.75em; }
406415
</style>
407416
</head>
408417
<body>
409418
${body}
419+
<footer class="deploy-footer">
420+
deployed from <code>${h(DEPLOY_BRANCH)}</code> &middot; <code>${h(DEPLOY_SHA)}</code> &middot; ${h(DEPLOY_DATE)}
421+
</footer>
410422
</body>
411423
</html>`;
412424
}

sharing-server/src/server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ import { getDb, closeDb, restoreFromBackup, backupToAzureFiles, syncAdminLogins
77
const app = new Hono();
88

99
// Health check — no auth required
10-
app.get('/health', (c) => c.json({ status: 'ok', timestamp: new Date().toISOString() }));
10+
app.get('/health', (c) => c.json({
11+
status: 'ok',
12+
timestamp: new Date().toISOString(),
13+
version: {
14+
sha: process.env.DEPLOY_SHA ?? 'unknown',
15+
branch: process.env.DEPLOY_BRANCH ?? 'unknown',
16+
date: process.env.DEPLOY_DATE ?? 'unknown',
17+
},
18+
}));
1119

1220
// API routes (Bearer GitHub token auth)
1321
app.route('/api', api);

0 commit comments

Comments
 (0)