From 6f80cadbd4199d89b27ff5f805951c9080cff9f1 Mon Sep 17 00:00:00 2001 From: "CTO (LegalAI)" Date: Thu, 9 Apr 2026 20:58:50 +0000 Subject: [PATCH] feat: add build hash to sidebar footer and Gitea CI/CD deploy workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Inject git commit short hash at build time via NEXT_PUBLIC_BUILD_HASH - Display build hash in sidebar footer for version tracking - Add Gitea Actions workflow to auto-deploy on push to master (SSH → pull → rebuild) Co-Authored-By: Paperclip --- .gitea/workflows/deploy.yml | 24 ++++++++++++++++++++++++ next.config.ts | 12 ++++++++++++ src/components/layout/sidebar.tsx | 3 +++ 3 files changed, 39 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..35adbc7 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,24 @@ +name: Deploy to VPS + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.VPS_HOST }} + username: ${{ secrets.VPS_USER }} + key: ${{ secrets.VPS_SSH_KEY }} + port: ${{ secrets.VPS_PORT || 22 }} + script: | + cd ${{ secrets.VPS_PROJECT_PATH || '/opt/legalai' }} + git pull origin master + docker compose build app + docker compose up -d app + echo "Deployed commit: $(git rev-parse --short HEAD)" diff --git a/next.config.ts b/next.config.ts index 1cdd52b..2068f1f 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,8 +1,20 @@ import type { NextConfig } from "next"; +import { execSync } from "child_process"; + +const commitHash = (() => { + try { + return execSync("git rev-parse --short HEAD").toString().trim(); + } catch { + return "dev"; + } +})(); const nextConfig: NextConfig = { output: "standalone", serverExternalPackages: ["pdf-parse", "drizzle-orm", "pg"], + env: { + NEXT_PUBLIC_BUILD_HASH: commitHash, + }, }; export default nextConfig; diff --git a/src/components/layout/sidebar.tsx b/src/components/layout/sidebar.tsx index e7b9607..fd5f052 100644 --- a/src/components/layout/sidebar.tsx +++ b/src/components/layout/sidebar.tsx @@ -52,6 +52,9 @@ export default function Sidebar() {
+
+

Build {process.env.NEXT_PUBLIC_BUILD_HASH || 'dev'}

+
); }