Conversation
lefthook's own npm postinstall already skips itself under CI=true by default (only installs if LEFTHOOK=1/true is explicitly set). Our prepare script called 'lefthook install' directly, which bypasses that and always runs regardless of environment. '|| exit 0' stopped the crash but still attempted the install in CI every time. This skips it outright, since hooks have no purpose in a non-interactive build. Same fix already applied on bcgov/namex#2019.
Google Cloud Build does not set CI=true (confirmed via a real CD run with the previous version of this fix - it still hit the git-not-found crash, since the [ "$CI" = "true" ] check was always false there). GitHub Actions sets CI=true automatically but this app's actual build happens inside a Cloud Build step invoked from within the Action, and that inner environment doesn't inherit it. Check for git's actual presence instead, which is what we care about and doesn't depend on any particular CI system's conventions.
panish16
added a commit
to panish16/namex
that referenced
this pull request
Sep 25, 2026
CI=true isn't a safe assumption across CI systems - confirmed on bcgov/bcregistry#282 that Google Cloud Build doesn't set it at all, so that version of this guard would have silently kept failing there despite looking correct. Checking for git's actual presence instead doesn't depend on any CI provider's conventions.
This was referenced Sep 25, 2026
Collaborator
Author
|
/gcbrun |
Collaborator
|
Temporary Url for review: https://yfthig-dev--pr-282-g8xemlex.web.app |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves on #281's guard, per feedback from Thor and Patrick that lefthook shouldn't be attempting to run in CI/CD at all, not just fail-safe.
What changed
Why not
CI=true, which was the first thing triedlefthook's own npm postinstall already skips itself under
CI=trueby default. Tried makingpreparedo the same ([ "$CI" = "true" ] || lefthook install) and pushed it through a real CD run first rather than assuming - it still hit the original crash. Google Cloud Build does not setCI=truein the build step, so that check was always false there. GitHub Actions does set it automatically, but this app's actual build runs inside a Cloud Build step invoked from within the Action, and that inner environment doesn't inherit the Action's env.Checking for
gitdirectly avoids depending on any particular CI system's conventions and matches the actual failure mode.Verified
Pushed this exact change through a real CD run (dev target): install completes with
prepare: Doneand nogit: executable file not foundline at all now, then deployed successfully to https://yfthig-dev.web.app.