I’m trying to figure out which commit is currently deployed on one of my Netlify sites. The deploy log said it was commited from /refs/head/master but I can’t pinpoint which commit that actually was. What’s the best way to find this information?
Since we clone your repo into the environment, you can ask the LOCAL copy for details - you can run things like git log. You cannot connect to remote repos since we have dropped all git permissions before we run your build. FYI we only specify “HEAD” as the source as your screenshot shows, when you trigger a deploy NOT via git; otherwise there will be a $COMMIT_REF with what your git provider has told us.
Hey @fool thanks for the response. I’m confused by what you mean re: asking the LOCAL copy for details. Is this something I do through the Netlify CLI?
Also, I have noticed the “HEAD” vs $COMMIT_REF based on how the deploy was triggered, but I’m not sure why the logs don’t provide both the “HEAD” and the commit/SHA the HEAD is pointing to. Seems like it would be easy enough to determine that when a manual deploy is triggered.
Anyway, if you could clarify the steps to inspecting the commit, that’d be super helpful. Thank you.
What @fool meant was to add the command git log as part of your build command. Something like git log; npm run build should bet the output of the git log before your build starts. Let me know if that helps.
thanks Dennis this worked! For anyone visiting this thread, I ended up using the command git log -1;yarn build, where the “-1” indicates it should only print the most recent log (you could use git log -3 to show most recent 3, for instance). Without that flag, it prints a TON of log messages from my git history.
FYI: you’ll want to use git log -1 && yarn build if the git log -1 output failing means that you don’t want the build to proceed & potentially be published. As you have it specified now, you could run some nonsense command ; yarn build and we’d still publish your site. Not sure if that matters, just wanted to be explicit since semicolons in build commands can lead to people doing something like:
yarn build ; echo finished
…and then it doesn’t matter if the yarn build worked - we’re publishing since the echo succeeded!