Skip to content

Commit c67f3b4

Browse files
skeptomaiclaude
andcommitted
feat: Add build version watermark to staging site
- Added version watermark in bottom-right corner (staging only) - Shows git commit hash and deployment timestamp - Helps verify cache invalidation is working - Automatically injected by deployment script during staging deploy - Hidden on production Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent c9227f5 commit c67f3b4

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

frontend/app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,19 @@ async function initApp() {
450450
await loadGameLibrary();
451451
await checkAdminRole(); // Check if user is admin
452452
}
453+
454+
// Show version watermark on staging
455+
const isStaging = API_BASE.includes('staging') || API_BASE.includes('localhost');
456+
if (isStaging) {
457+
const watermark = document.getElementById('version-watermark');
458+
const buildVersion = document.getElementById('build-version');
459+
if (watermark && buildVersion) {
460+
// Build version will be injected by deployment script
461+
// Format: COMMIT_HASH @ TIMESTAMP
462+
buildVersion.textContent = buildVersion.textContent || 'DEV';
463+
watermark.style.display = 'block';
464+
}
465+
}
453466
}
454467

455468
// Logout

frontend/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ <h3 onclick="toggleVisualSettings()" style="cursor: pointer;">
400400
</defs>
401401
</svg>
402402

403+
<!-- Version watermark for staging (shows deployment info) -->
404+
<div id="version-watermark" style="position: fixed; bottom: 0; right: 0; background: rgba(0,0,0,0.7); color: #666; padding: 5px 10px; font-size: 10px; font-family: monospace; z-index: 9999; display: none;">
405+
Build: <span id="build-version">DEV</span>
406+
</div>
407+
403408
<script type="module" src="app.js"></script>
404409
</body>
405410
</html>

infrastructure/scripts/deploy-frontend.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,27 @@ echo ""
3434
# Navigate to frontend directory
3535
cd "$(dirname "$0")/../../frontend"
3636

37+
# Generate build version info (git commit hash + timestamp)
38+
COMMIT_HASH=$(git -C .. rev-parse --short HEAD 2>/dev/null || echo "unknown")
39+
BUILD_TIME=$(date -u +"%Y-%m-%d %H:%M UTC")
40+
BUILD_VERSION="${COMMIT_HASH} @ ${BUILD_TIME}"
41+
42+
echo "Build version: $BUILD_VERSION"
43+
echo ""
44+
45+
# Inject build version into HTML (only for staging)
46+
if [ "$ENV" == "staging" ]; then
47+
# Create temporary HTML with build version injected
48+
sed "s/<span id=\"build-version\">DEV<\/span>/<span id=\"build-version\">$BUILD_VERSION<\/span>/" index.html > index.tmp.html
49+
mv index.tmp.html index.deploy.html
50+
else
51+
# Use original HTML for production (no watermark)
52+
cp index.html index.deploy.html
53+
fi
54+
3755
# Upload files to S3
3856
echo "Uploading files to S3..."
39-
aws s3 cp index.html "s3://$BUCKET/index.html" \
57+
aws s3 cp index.deploy.html "s3://$BUCKET/index.html" \
4058
--content-type "text/html" \
4159
--cache-control "no-cache, no-store, must-revalidate" \
4260
--metadata-directive REPLACE
@@ -85,3 +103,6 @@ echo "URL: https://$DOMAIN"
85103
echo ""
86104
echo "Note: CloudFront invalidation may take 1-3 minutes"
87105
echo "Check status: aws cloudfront get-invalidation --distribution-id $DISTRIBUTION_ID --id $INVALIDATION_ID"
106+
107+
# Cleanup temporary file
108+
rm -f index.deploy.html

0 commit comments

Comments
 (0)