简体   繁体   中英

How to set a different NODE_ENV for my master and develop Git branches in my Google App Engine app.yaml file?

This is what my app.yaml file for Google App Engine current looks like:

# [START app_yaml]
runtime: nodejs
vm: true
env_variables:
    PORT: 8080
    NODE_ENV: development
# [END app_yaml]

I have two Git branches:

  • master
  • develop

I deploy to the staging project from the develop branch and to the production project from the master branch. I want to set the NODE_ENV variable to production only when I deploy from the master branch. Is this possible? If not, how do you all manage this?

Note: I am new to Google App Engine. I am unsure if this is how you even deploy to staging and production servers in the first place. If you have a better solution, please share.

You could have the content of the app.yaml different in the 2 branches. I'd also set the app name in the yaml file to the respective develop/production app instead of specifying it via args at deployment time, to prevent acidental deployment to the wrong app.

The develop branch app.yaml :

application: my_app_dev
runtime: nodejs
vm: true
env_variables:
    PORT: 8080
    NODE_ENV: development

The master branch app.yaml :

application: my_app
runtime: nodejs
vm: true
env_variables:
    PORT: 8080
    NODE_ENV: production

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM