Skip to content

Commit 17fbd14

Browse files
committed
Pass git hash as arg in docker build
1 parent 5ddd62b commit 17fbd14

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
provenance: false
3737
cache-from: type=gha
3838
cache-to: type=gha,mode=max
39+
build-args: GIT_HASH=${{ github.sha }}
3940

4041
build-binaries:
4142
strategy:

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ RUN npm ci
55

66

77
FROM node:20.15.0 AS build
8+
ARG GIT_HASH=""
9+
ENV GIT_HASH ${GIT_HASH}
810
WORKDIR /app
911
COPY --from=deps /app/node_modules ./node_modules
1012
COPY . .

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import react from "@vitejs/plugin-react";
66
import tsconfigPaths from "vite-tsconfig-paths";
77
import * as child from "child_process";
88

9-
const commitHash = child.execSync("git rev-parse HEAD").toString();
9+
const commitHash = process.env.GIT_HASH || child.execSync("git rev-parse HEAD").toString();
1010

1111
// https://vitejs.dev/config/
1212
export default defineConfig(async () => ({

0 commit comments

Comments
 (0)