feat: show build commit on admin page

This commit is contained in:
root
2026-03-24 23:51:42 +01:00
parent fc67533db9
commit fa8c6d02fd
5 changed files with 20 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
FROM golang:1.26-alpine AS builder FROM golang:1.26-alpine AS builder
ARG GIT_COMMIT=dev
WORKDIR /app WORKDIR /app
@@ -13,7 +14,7 @@ COPY . .
ENV CGO_ENABLED=1 ENV CGO_ENABLED=1
ENV GIN_MODE=release ENV GIN_MODE=release
RUN go build -o app ./cmd/server RUN go build -ldflags "-X ResendIt/internal/buildinfo.Commit=${GIT_COMMIT}" -o app ./cmd/server
FROM alpine:latest FROM alpine:latest

4
Jenkinsfile vendored
View File

@@ -40,7 +40,9 @@ pipeline {
sh """ sh """
docker version docker version
docker build -t ${IMAGE}:${IMAGE_TAG_SHA} . docker build \
--build-arg GIT_COMMIT=${IMAGE_TAG_SHA} \
-t ${IMAGE}:${IMAGE_TAG_SHA} .
""" """
} }
} }

View File

@@ -0,0 +1,7 @@
package buildinfo
// Commit is the git commit SHA the binary was built from.
//
// Set at build time via:
// -ldflags "-X ResendIt/internal/buildinfo.Commit=<sha>"
var Commit = "dev"

View File

@@ -1,6 +1,7 @@
package web package web
import ( import (
"ResendIt/internal/buildinfo"
"ResendIt/internal/file" "ResendIt/internal/file"
"os" "os"
"strconv" "strconv"
@@ -108,9 +109,10 @@ func (h *Handler) AdminPage(c *gin.Context) {
totalPages := (totalCount + limit - 1) / limit totalPages := (totalCount + limit - 1) / limit
c.HTML(200, "admin.html", gin.H{ c.HTML(200, "admin.html", gin.H{
"Files": adminFiles, "Files": adminFiles,
"Page": page, "Page": page,
"TotalPages": totalPages, "TotalPages": totalPages,
"BuildCommit": buildinfo.Commit,
}) })
} }

View File

@@ -209,6 +209,9 @@
<div class="text-[12px] font-black uppercase"> <div class="text-[12px] font-black uppercase">
Data_Density: {{len .Files}} records | Page: {{.Page}}/{{.TotalPages}} Data_Density: {{len .Files}} records | Page: {{.Page}}/{{.TotalPages}}
</div> </div>
<div class="text-[11px] font-black uppercase text-gray-600">
Build_Commit: {{.BuildCommit}}
</div>
</footer> </footer>
</div> </div>
</div> </div>