diff --git a/Dockerfile b/Dockerfile index 414f5f4..7282179 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,10 @@ WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci -# Build the static site. +# Build the static site. The git sha arrives as a build-arg (.dockerignore excludes .git, +# so an in-container `git rev-parse` can never resolve — the footer receipt read "HEAD unknown"). +ARG GIT_SHA +ENV GIT_SHA=${GIT_SHA} COPY . . RUN npm run build diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 8f6f3a9..b97660f 100755 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -31,7 +31,7 @@ retry() { } echo ">> building ${REF}:${TAG}" -retry buildah build --retry 3 --retry-delay 5s --layers -t "${REF}:${TAG}" -t "${REF}:latest" . +retry buildah build --retry 3 --retry-delay 5s --layers --build-arg GIT_SHA="${TAG}" -t "${REF}:${TAG}" -t "${REF}:latest" . if [[ "${1:-}" == "push" ]]; then echo ">> pushing ${REF}:${TAG}" diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 92c67df..a85e608 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -7,156 +7,260 @@ const linkedinHref = socials.find((s) => s.label === "LinkedIn")?.href; const emailHref = socials.find((s) => s.label === "Email")?.href; --- + diff --git a/src/lib/build-info.ts b/src/lib/build-info.ts index e486f33..fa2435e 100644 --- a/src/lib/build-info.ts +++ b/src/lib/build-info.ts @@ -11,8 +11,10 @@ function git(cmd: string): string { } export const buildInfo = { - /** Short commit sha of the source HEAD this build was cut from. */ - sha: git("git rev-parse --short HEAD"), + /** Short commit sha of the source HEAD this build was cut from. + * Container builds get it via the GIT_SHA build-arg (.dockerignore excludes .git); + * local builds fall back to asking git directly. */ + sha: process.env.GIT_SHA?.trim() || git("git rev-parse --short HEAD"), /** ISO date (UTC, minute precision) the build ran. */ builtAt: new Date().toISOString().slice(0, 16).replace("T", " ") + "Z", } as const;