Skip to content

Commit 88dd9e8

Browse files
rz1989sclaude
andcommitted
feat: Add deployment version footer with branch and commit tracking
Implements production deployment visibility by displaying current branch and commit SHA in a fixed footer, with direct links to GitHub. Features: - VersionHelper module for reading REVISION file (SHA|BRANCH format) - Version footer component with branch and commit display - GitHub icons with clickable links to commit/branch pages - Deployment timestamp with "time ago" tooltip - Mobile-responsive design (hides label on small screens) - Styled to match NFT-inspired design system GitHub Actions integration: - Auto-generates REVISION file during deployment - Displays: "Production: main @ abc1234" - Enables instant verification of deployed version Benefits: Quick debugging, deployment tracking, rollback verification, and team coordination for production monitoring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9508676 commit 88dd9e8

File tree

6 files changed

+175
-1
lines changed

6 files changed

+175
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ jobs:
4141
4242
echo "🚀 Starting deployment..."
4343
44-
cd ~/core
44+
cd ~/apps/core
4545
4646
# Pull latest changes
4747
echo "📥 Pulling latest code from main..."
4848
git fetch origin
4949
git reset --hard origin/main
5050
51+
# Generate REVISION file with commit SHA and branch
52+
echo "📝 Generating REVISION file..."
53+
COMMIT_SHA=$(git rev-parse HEAD)
54+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
55+
echo "${COMMIT_SHA}|${BRANCH}" > REVISION
56+
echo "✅ REVISION: ${BRANCH}@${COMMIT_SHA:0:7}"
57+
5158
# Install dependencies
5259
echo "📦 Installing dependencies..."
5360
bundle install --deployment --without development test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ Thumbs.db
7171
!/tmp/cache/.keep
7272
!/tmp/sockets/.keep
7373
!/tmp/storage/.keep
74+
REVISION

app/assets/tailwind/application.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,58 @@
6363
.code-block {
6464
@apply bg-brown text-cream p-6 rounded-lg overflow-x-auto my-6 text-[15px] leading-relaxed;
6565
}
66+
67+
/* Version Footer - Deployment Info */
68+
.version-footer {
69+
@apply fixed bottom-4 right-4 z-50;
70+
}
71+
72+
.version-info {
73+
@apply flex items-center gap-2 bg-brown/90 text-cream px-3 py-2 rounded-lg;
74+
@apply backdrop-blur-sm shadow-lg;
75+
@apply text-xs font-mono;
76+
}
77+
78+
.version-label {
79+
@apply text-yellow/80 font-medium;
80+
}
81+
82+
.version-link {
83+
@apply flex items-center gap-1.5 no-underline;
84+
@apply text-cream/90 transition-colors duration-200;
85+
}
86+
87+
.version-link:hover {
88+
@apply text-sky-blue;
89+
}
90+
91+
.version-icon {
92+
@apply flex-shrink-0 opacity-75;
93+
}
94+
95+
.version-branch {
96+
@apply text-green font-medium;
97+
}
98+
99+
.version-sha {
100+
@apply text-cream/90;
101+
}
102+
103+
.version-separator {
104+
@apply text-cream/40;
105+
}
106+
107+
@media (max-width: 640px) {
108+
.version-footer {
109+
@apply bottom-2 right-2;
110+
}
111+
112+
.version-info {
113+
@apply px-2 py-1.5 text-[10px];
114+
}
115+
116+
.version-label {
117+
@apply hidden;
118+
}
119+
}
66120
}

app/helpers/version_helper.rb

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# frozen_string_literal: true
2+
3+
module VersionHelper
4+
# Returns the current git commit SHA from REVISION file
5+
# Returns nil if file doesn't exist (development/test)
6+
def current_commit_sha
7+
version_info = read_version_file
8+
version_info[:sha]
9+
end
10+
11+
# Returns the current git branch name
12+
def current_branch
13+
version_info = read_version_file
14+
version_info[:branch]
15+
end
16+
17+
# Returns short version of commit SHA (first 7 characters)
18+
def short_commit_sha
19+
sha = current_commit_sha
20+
sha ? sha[0..6] : nil
21+
end
22+
23+
# Returns GitHub URL for the current commit
24+
def commit_github_url
25+
sha = current_commit_sha
26+
return nil unless sha
27+
28+
"https://github.com/RECTOR-LABS/core/commit/#{sha}"
29+
end
30+
31+
# Returns GitHub URL for the current branch
32+
def branch_github_url
33+
branch = current_branch
34+
return nil unless branch
35+
36+
"https://github.com/RECTOR-LABS/core/tree/#{branch}"
37+
end
38+
39+
# Returns deployment timestamp from REVISION file modification time
40+
def deployment_timestamp
41+
revision_file = Rails.root.join("REVISION")
42+
return nil unless revision_file.exist?
43+
44+
File.mtime(revision_file)
45+
end
46+
47+
# Returns formatted deployment time (e.g., "2 hours ago")
48+
def deployment_time_ago
49+
timestamp = deployment_timestamp
50+
return nil unless timestamp
51+
52+
time_ago_in_words(timestamp)
53+
end
54+
55+
private
56+
57+
# Reads and parses the REVISION file
58+
# Format: SHA|BRANCH (e.g., "abc123def456|main")
59+
def read_version_file
60+
return @version_info if defined?(@version_info)
61+
62+
revision_file = Rails.root.join("REVISION")
63+
unless revision_file.exist?
64+
@version_info = { sha: nil, branch: nil }
65+
return @version_info
66+
end
67+
68+
content = revision_file.read.strip
69+
parts = content.split("|")
70+
71+
@version_info = {
72+
sha: parts[0]&.strip,
73+
branch: parts[1]&.strip || "unknown"
74+
}
75+
end
76+
end

app/views/layouts/application.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727
<main class="container mx-auto mt-28 px-5 flex">
2828
<%= yield %>
2929
</main>
30+
31+
<%= render "shared/version_footer" %>
3032
</body>
3133
</html>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<% if Rails.env.production? && short_commit_sha.present? %>
2+
<footer class="version-footer">
3+
<div class="version-info">
4+
<span class="version-label">Production:</span>
5+
6+
<!-- Branch -->
7+
<% if current_branch.present? %>
8+
<%= link_to branch_github_url,
9+
target: "_blank",
10+
rel: "noopener noreferrer",
11+
class: "version-link branch-link",
12+
title: "View #{current_branch} branch on GitHub" do %>
13+
<svg class="version-icon" viewBox="0 0 16 16" width="12" height="12" aria-hidden="true">
14+
<path fill="currentColor" d="M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"></path>
15+
</svg>
16+
<code class="version-branch"><%= current_branch %></code>
17+
<% end %>
18+
<span class="version-separator">@</span>
19+
<% end %>
20+
21+
<!-- Commit -->
22+
<%= link_to commit_github_url,
23+
target: "_blank",
24+
rel: "noopener noreferrer",
25+
class: "version-link commit-link",
26+
title: "View commit on GitHub (deployed #{deployment_time_ago} ago)" do %>
27+
<svg class="version-icon" viewBox="0 0 16 16" width="12" height="12" aria-hidden="true">
28+
<path fill="currentColor" d="M11.93 8.5a4.002 4.002 0 01-7.86 0H.75a.75.75 0 010-1.5h3.32a4.002 4.002 0 017.86 0h3.32a.75.75 0 010 1.5h-3.32zM8 6a2 2 0 100 4 2 2 0 000-4z"></path>
29+
</svg>
30+
<code class="version-sha"><%= short_commit_sha %></code>
31+
<% end %>
32+
</div>
33+
</footer>
34+
<% end %>

0 commit comments

Comments
 (0)