Build SHA as env variable

2 years ago

Can I expose the current build SHA as an env var to the app?

15 Replies

2 years ago

Would probably need to use dockerfile and define an env var there with some kind of library you add during build


2 years ago

ty, ideally it would be the git SHA for the current release


2 years ago

hmmm


2 years ago

RAILWAYDEPLOYMENTID


2 years ago

maybe this would work


2 years ago

RAILWAYGITCOMMIT_SHA


2 years ago

oooo


2 years ago

even better!!


blarfoon
PRO

a year ago

@macwilko how did you solve this? I tried using RAILWAY_GIT_COMMIT_SHA but I get an empty string


a year ago

RAILWAY_GIT_COMMIT_SHA works fine.

1361081167453094100


a year ago

are you perhaps trying to reference it in a service variable? or are you using a dockerfile?


blarfoon
PRO

a year ago

oh I can't reference it from a service variable? I was trying to create an alias to APP_VERSION


blarfoon
PRO

a year ago

I will reference it directly then, thanks


blarfoon
PRO

a year ago

it's weird that some variables work and some don't. RAILWAY_ENVIRONMENT_NAME for example can be used in service variables just fine


a year ago

the SHA variable is a dynamic variable and by its nature would only be available on container build and start since it's only know when you push to GitHub, how would the dashboard have any way of knowing it's value?


Loading...