Executing "git rev-parse --short HEAD" crashes deployment
Hey there,
I'm creating another instance of my project, currently it's running on AWS and I intend to create the Railway one too.
In my NestJS project I have a line that "Health Check" status route that returns some data and alongside it a git hash.
revision: child_process.execSync('git rev-parse --short HEAD').toString().trim()
I'm using Docker as my builder, and in it I have a RUN apk add --no-cache git
Deploy Logs are saying next:
I saw that Railway provides the env RAILWAY_GIT_COMMIT_SHA
but , I'm not sure if I can refactor it and make it work on AWS too. I fetch the shortened SHA inside a config object of an imported module.14 Replies
Project ID:
f62c745f-4126-4c82-9c45-02417891d65e
project-id: f62c745f-4126-4c82-9c45-02417891d65e
just slap in some logic like
if railway return RAILWAY_GIT_COMMIT_SHA else return git hash
Solution
You're right!
What about
looks good to me
but this raises the question, do you really need to be returning the git hash?
In a health check route?
yeah
🤷♂️
That's the way it worked for a loooong time
whats the purpose of returning the git hash?
Checking if it deployed the right commit
fair enough
I'm trying out the logic and I hope that it will work 💪
@Brody You sir, are a gentleman and a scholar! Thanks a lot!
pseudo code ftw
happy to help! 🙂