I have two separate apps on Heroku that are very similar so they share the same master codebase. They are each set up as a different environment. They only differ in the values of a few environment variables. That's all working fine because environment variables can be set per environment.
But in addition the environment variables, there is one file that needs to be different between the two environments. This file needs to be named the same, but must have different contents.
How can I deploy one file in one environment and a different file in another?
This is hard to answer without knowing what type of file it is and what language you're using.
A generic approach would be to have both files in the code base, such sample_file_env_1.txt
and sample_file_env_2.txt
and then in your Procfile
or app startup script, invoke another script to copy that file to the location you're expecting depending on the environment variables set.