const sourceCommit: string = process.env.VERCEL_GIT_COMMIT_SHA ?? “unknown”; it is empty, i expect the git commit hash
How do get a git commit hash variable ? Do I need to type _.env ?
I cannot understand the wiki : System environment variables ← how do I run this command : VERCEL_GIT_COMMIT_SHA=fa1eade47b73733d6312d5abfad33ce9e4068081
app router “next”: “15.1.3” , using vercel project
THe above steps should do the ticket. Are you reading commit SHA in source code (runtime) or during build (build step)? You can replace buildCommand with echo $VERCEL_GIT_COMMIT_SHA && npm run build or similar to figure out if the env var indeed available or not
Environment variables are by default only available on the server side. To access Vercel’s system environment variables like VERCEL_GIT_COMMIT_SHA on the client side, you need to follow a specific approach.
Option 1: Expose it with NEXT_PUBLIC prefix
You’ll need to create a new environment variable that’s prefixed with NEXT_PUBLIC_ and assign the value of VERCEL_GIT_COMMIT_SHA to it. This can be done in your project settings or build configuration.
hi Swarnava, using process.env.VERCEL_GIT_COMMIT_SHA locally returns a hash that is not match last commit
a) git rev-parse origin/main 37d9d82e9f27ae2a7694cec9a83e8c3ac1afc6b9 vs
b) 112233445566
vercel cli - this does not populate the project env variable - not sure why ??
npx convex deploy --cmd ‘set NEXT_PUBLIC_GIT_COMMIT_SHA = $VERCEL_GIT_COMMIT_SHA && npm run build’
githubCommitRef=“feature/branch-name” <-What does feature mean ?
My repo is zork0 , and I have 2 branches : master and main
I tried : vercel --prod -m githubDeployment=“1” -m githubCommitRef=“zork0/main” but l do not work
Here is my vercel build command:
npx convex deploy --cmd ‘set NEXT_PUBLIC_GIT_COMMIT_SHA = $VERCEL_GIT_COMMIT_SHA && npm run build’