Add commit SHA and build date to website footer

- Display short commit SHA with link to GitHub commit
- Show build date in YYYY-MM-DD format
- Use GITHUB_SHA env var in CI, fallback to git command locally
- Add subtle styling for build info text
This commit is contained in:
Aaron Powell
2026-02-03 10:38:16 +11:00
parent 612f5e4208
commit f4c2e0b0e0
2 changed files with 30 additions and 0 deletions

View File

@@ -688,6 +688,12 @@ a:hover {
color: var(--color-accent);
}
.site-footer .build-info {
margin-top: 8px;
font-size: 12px;
opacity: 0.7;
}
/* Buttons */
.btn {
display: inline-flex;

View File

@@ -1,4 +1,6 @@
---
import { execSync } from "child_process";
interface Props {
title: string;
description?: string;
@@ -11,6 +13,21 @@ const {
activeNav = "",
} = Astro.props;
const base = import.meta.env.BASE_URL;
// Get git commit SHA and build date at build time
let commitSha = "unknown";
let buildDate = new Date().toISOString().split("T")[0];
try {
// Use GITHUB_SHA env var in GitHub Actions, fallback to git command locally
const githubSha = process.env.GITHUB_SHA;
if (githubSha) {
commitSha = githubSha.substring(0, 7);
} else {
commitSha = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
}
} catch {
// Fallback if git is not available
}
---
<!doctype html>
@@ -155,6 +172,13 @@ const base = import.meta.env.BASE_URL;
rel="noopener">MIT License</a
>
</p>
<p class="build-info">
Built from <a
href={`https://github.com/github/awesome-copilot/commit/${commitSha}`}
target="_blank"
rel="noopener">{commitSha}</a
> on {buildDate}
</p>
</div>
</footer>