app.yaml can set environment variables for the rest of the application, but it does not have the ability to check them and do different things depending on their input values. Thus, you need to submit various app.yaml files for any deployment procedure used.
As for the best way to prepare the right app.yaml as a preliminary step to deploying GAE, there is a problem with finer decompression. Branches in your git or hg, etc., as you mention, will work, but in person (maybe just a failure?). I often found that the simpler my structure, the better the branches intended for longevity (unlike temporary deviations, which should soon merge back into the trunk), gave me worse headaches.
So, it all depends on me, I would have a preapp.yaml template (maybe jinja2, whatever) with the necessary if / else logic and prepare the correct app.yaml from it, as the very first step of any deployment with a simple Python script.
A largely used architecture (for all types of configuration files, and therefore with more inevitable complications) for the gcloud preview deployment-manager beta, see https://cloud.google.com/deployment-manager/ , so of course , I could be biased towards the approach (but, as I mentioned, my bias is essentially due to previous failed deployment events :-).
source share