The etc/env.php file is different for each environment, like for your local, staging and production. That means you can not edit this file and push this file from your local setup to the cloud environment as this is ignored by Git. In some situations, you have to add some variables or edit values in the /app/etc/env.php file. If you are considering how to edit the env.php file in Magneto 2 commerce cloud or Adobe commerce cloud then this blog post by Dhairvi Solutions is for you.
There is a magical file there for us in the Magento commerce cloud to achieve our requirement of how to update env.php file the name of file is .magento.env.yaml
You can add/update any values of /app/etc/env.php by adding it under “deploy:” of .magento.env.yaml
Below is the format of how you can add/update any variable and its value
stage: deploy: DEPLOY_VARIABLE_NAME: value
When the Magento commerce cloud environment deploys or you push any changes from your local to Magento 2 commerce cloud branch that changes part executed and deploy those variables to etc/env.php
So set up your deployment strategy from .magento.env.yaml and play with commerce cloud to know more 🙂
Feel free to ask me about your any Magento commerce cloud to me and I will be happy to assist with that.