How to check the site is in the first building process?

I would like to thank the netlify team for the amazing product that help us to be more productive people.

Regarding the topic, I’ve built a netlify plugin that skips any non-affected apps in nx monorepo,

https://github.com/f22hd/netlify-plugin-nx-skip-build/issues/7

I would to cover one case where if the site is in the first building process, so based on current implementation will be blocked by the result of comparing two git hashes.

I am wondering, is any variable that I can get the info about if the site is in the first build?

Thanks in advance.

I found the solution, just comparing between

   const firstDeployment = process.env.CACHED_COMMIT_REF === process.env.COMMIT_REF

docs:

https://docs.netlify.com/configure-builds/environment-variables/#git-metadata

we can close this post.

1 Like

Thanks so much for coming back and letting us know! Glad you found a solution.