Are you using something like mupx for deployments? If so you could handle this in advance by wrapping your mupx call in a shell script, that first sets up the appropriate robots.txt file based on environment. For example:
your_app_root/deploy/robots.prod.txt
your_app_root/deploy/robots.staging.txt
your_app_root/deploy/deploy.sh
deploy.sh would look something like:
#!/bin/bash
robots="robots.prod.txt"
if [ "$1" = "staging" ];
then
robots="robots.staging.txt"
fi
cp $robots ../public/robots.txt
mupx deploy
When deploy.sh is run it would overwrite your apps existing /public/robots.txt with the production one, then continue to deploy via mupx. If called as “deploy.sh staging” it would overwrite with the staging one, and continue to deploy.