nsarrazin HF Staff commited on
Commit
623efa6
·
unverified ·
1 Parent(s): 31f8c3d

feat: commit id in settings (#1507)

Browse files

* feat: display commit in settings

* feat: styling of commit id message

* fix: build error

.env CHANGED
@@ -177,4 +177,6 @@ HF_ORG_ADMIN=
177
  HF_ORG_EARLY_ACCESS=
178
 
179
  PUBLIC_SMOOTH_UPDATES=false
180
- COMMUNITY_TOOLS=false
 
 
 
177
  HF_ORG_EARLY_ACCESS=
178
 
179
  PUBLIC_SMOOTH_UPDATES=false
180
+ COMMUNITY_TOOLS=false
181
+
182
+ PUBLIC_COMMIT_SHA=
Dockerfile CHANGED
@@ -3,17 +3,11 @@
3
  # you will also find guides on how best to write your Dockerfile
4
  ARG INCLUDE_DB=false
5
 
6
- # stage that install the dependencies
7
- FROM node:20 AS builder-production
8
 
9
  WORKDIR /app
10
 
11
  COPY --link --chown=1000 package-lock.json package.json ./
12
- RUN --mount=type=cache,target=/app/.npm \
13
- npm set cache /app/.npm && \
14
- npm ci --omit=dev
15
-
16
- FROM builder-production AS builder
17
 
18
  ARG APP_BASE=
19
  ARG PUBLIC_APP_COLOR=blue
@@ -25,7 +19,8 @@ RUN --mount=type=cache,target=/app/.npm \
25
 
26
  COPY --link --chown=1000 . .
27
 
28
- RUN npm run build
 
29
 
30
  # mongo image
31
  FROM mongo:7 AS mongo
 
3
  # you will also find guides on how best to write your Dockerfile
4
  ARG INCLUDE_DB=false
5
 
6
+ FROM node:20 AS builder
 
7
 
8
  WORKDIR /app
9
 
10
  COPY --link --chown=1000 package-lock.json package.json ./
 
 
 
 
 
11
 
12
  ARG APP_BASE=
13
  ARG PUBLIC_APP_COLOR=blue
 
19
 
20
  COPY --link --chown=1000 . .
21
 
22
+ RUN git config --global --add safe.directory /app && \
23
+ PUBLIC_COMMIT_SHA=$(git rev-parse HEAD) && npm run build
24
 
25
  # mongo image
26
  FROM mongo:7 AS mongo
src/routes/settings/(nav)/+page.svelte CHANGED
@@ -17,11 +17,15 @@
17
  </script>
18
 
19
  <div class="flex w-full flex-col gap-5">
20
- <div class="flex items-start justify-between text-xl font-semibold text-gray-800">
21
  <h2>Application Settings</h2>
 
 
 
 
 
22
  </div>
23
-
24
- <div class="flex h-full flex-col gap-4 pt-4 max-sm:pt-0">
25
  {#if envPublic.PUBLIC_APP_DATA_SHARING === "1"}
26
  <!-- svelte-ignore a11y-label-has-associated-control -->
27
  <label class="flex items-center">
 
17
  </script>
18
 
19
  <div class="flex w-full flex-col gap-5">
20
+ <div class="flex flex-col items-start justify-between text-xl font-semibold text-gray-800">
21
  <h2>Application Settings</h2>
22
+ <span class="text-sm font-light text-gray-500">
23
+ Latest deployment <span class="gap-2 font-mono"
24
+ >{envPublic.PUBLIC_COMMIT_SHA.slice(0, 7)}</span
25
+ >
26
+ </span>
27
  </div>
28
+ <div class="flex h-full flex-col gap-2 max-sm:pt-0">
 
29
  {#if envPublic.PUBLIC_APP_DATA_SHARING === "1"}
30
  <!-- svelte-ignore a11y-label-has-associated-control -->
31
  <label class="flex items-center">
svelte.config.js CHANGED
@@ -1,11 +1,21 @@
1
  import adapter from "@sveltejs/adapter-node";
2
  import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
3
  import dotenv from "dotenv";
4
-
5
  dotenv.config({ path: "./.env.local" });
6
  dotenv.config({ path: "./.env" });
7
 
 
 
 
 
 
 
 
 
 
8
  process.env.PUBLIC_VERSION ??= process.env.npm_package_version;
 
9
 
10
  /** @type {import('@sveltejs/kit').Config} */
11
  const config = {
 
1
  import adapter from "@sveltejs/adapter-node";
2
  import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
3
  import dotenv from "dotenv";
4
+ import { execSync } from "child_process";
5
  dotenv.config({ path: "./.env.local" });
6
  dotenv.config({ path: "./.env" });
7
 
8
+ function getCurrentCommitSHA() {
9
+ try {
10
+ return execSync("git rev-parse HEAD").toString();
11
+ } catch (error) {
12
+ console.error("Error getting current commit SHA:", error);
13
+ return "unknown";
14
+ }
15
+ }
16
+
17
  process.env.PUBLIC_VERSION ??= process.env.npm_package_version;
18
+ process.env.PUBLIC_COMMIT_SHA = getCurrentCommitSHA();
19
 
20
  /** @type {import('@sveltejs/kit').Config} */
21
  const config = {