A change is proved in development and in staging before it reaches live. Live is kept separate from the environments used to build and review, so testing does not affect people using the service.
The detail of branching, review, and approval is in Gitflow and releases. What must be true before a story is releasable is in Definition of done.
Staging and live use separate configuration and separate data. A change moves forward only through the release stages above. Secrets and certificates are not stored in source code.
Secure by design sets out environment separation, secrets, and the delivery controls around them.