We are using Github Action to deploy our code. On push, the source code will be pushed and we were able to build the code and deploy successfully if the config file is also tracked by the repository. However, we are encountering a problem with a config file in .gitignore.
Our app has different versions, controlled by this config file, and also this file is different from testing to production. Therefore, this file is standalone and not tracked by the git repository. However, for Github actions to build the project correctly, this file is necessary and has to be placed on a certain path of the project, e.g., /configs/env_configs.json
.
This seems like a very common use case but I find very little information in Github action's document.
Is there a good way to work this out?
There is concept of environments available in GitActions. You can create multiple such environments for each of your app versions. And there will be a variable(with same name) in each of these environments holding config data needed for your app to work. In your git actions you identify the branch on which your workflow is triggered and refer that environment name. The config data for that environment(basically your app version) is automatically referred. You can then redirect that variable output to a file in specific build path and can continue with further steps.
Check docs here: Git Actions Environments
Sample Git actions code might look like this