This is more a feature request than a question, because I am quite sure there is no workaround.
Whenever I try to deploy a Rmarkdown document with source that has environment variables as dependencies (say, an API key that I don't want exposed in the code), I have to first publish it without the lines referring/using the variable in question, so the deployment won't fail, and then republish/rerun after I added the particular variable in the content (using the page).
I wonder if there be a way to set the environment variables when one deploys the content. Note that the same situation happens regardless how one deploys: via the button in RStudio, via "deploy from git" or through the API. It is a bit annoying to be forced to deploy/rerun twice because of that.
In addition, I could use the same logic to the other content parameters, such as the "Run As" user or the content permissions. I am not sure that one can change on deployment (?), but that would be a fantastic addition to this very useful service.