I had 3 apps running perfectly with the same git repository.
My realm_config.json was omitting the “environment” property, so Realm was not changing it, it was using the one configured when I created the app.
Now every time I deploy it changes the environment to no-environment. I have no idea how to set one environment for each app in the same repo.
Can you please provide more details? You have three apps… using which Realm SDK? Android, iOS, JS…?
These three apps are in the same repo so to build one you switch branches, right? Can’t this file be added three times to the repo in each of these branches?
What do you mean for “deploy”? Build the app, run in Simulator, emulator, deploy as web app…?
Thanks for any info!
I have 3 Realm app with automatic deployment from Github enabled.
My 3 realm apps had the following environment mode: testing, development (watches the dev branch in GitHub) and qa (watches the staging branch in Github)
I have two branches in github: dev and staging. Also have local branches that I do the work before pushing to dev.
The app with testing mode is used for me to deploy from my local branch… So I deploy through Realm-CLI and test my Testing App. If it’s ok I push my changes to dev branch (which will trigger the auto deploy in Realm)
So my realm_config.json had the “environment” property omitted… So each app was correctly getting the environment values.
Now how am I supposed to have different values in realm_config.json for each branch? I would need to create a Github workflow to change the environment mode before pushing?
How would I push from dev to staging with different realm_config.json values?
My app is a nodejs app. I use the serverless functions and database triggers from Realm.
Sorry for many posts. But I think the environment mode should be handled like you handle the Secrets (I can change it and don’t need to save draft and deploy). The mode shouldn’t be in the realm_config.json file.
No problem at all for posting!
This is a bit out of my scope of knowledge, so I’ll ask around.
Have you read this article on How to build CI/CD pipelines with GitHub and Realm? It might help you to accomplish what you are looking for How to Build CI/CD Pipelines for MongoDB Realm Apps Using GitHub Actions | MongoDB
Hopes this help
I did read. With all due respect, it looks like a lot of workarounds. The workflow has 300 lines doing a lot of work. You guys should make things easier.
In that link, the Github workflow replaces the values in realm_config.json before pushing to the branch. As you can see in this line realm-demos/build.yml at main · mongodb-developer/realm-demos · GitHub this is a workaround for me.
I didnt want to do that, but seems you are going a way that I will have to do that.
In my opinion, ideally all apps should be the same, the only difference in them should be the environment values in each of the environment files.
But thanks for the quick responses. Hope you guys take this into consideration and change Realm to not set a default value for environment if there is one already set and the property was omitted
Hi Rafael, I’m having the same issue, but in addition to the environment property, there’s also the “name” property that exists in the new realm_config file. Do your 3 realm apps have the same or different names? If different names, how did you deal with the name property in the config file?
All apps have the same name. (Since the “name” property is hardcoded in realm conf file)
All databases have the same name. (Since the “database” property is hardcoded in the triggers conf file)
And as said earlier, I used to omit the environment mode, so Realm was using the one that I had configured when creating the app. It was working like a charm.
But out of a sudden, it started changing the environment mode to “no-environment”. So I had to do an ugly hack in CD workflow to edit the realm conf file on the fly based on the branch it was being pushed to.
But if your apps have different names and you don’t want to create new apps, you could change the name on the fly in your CD pipeline, just like changing the environment mode.
Hi Rafael, thank you for your reply! Different names might be confusing for our workflow because all the realm apps show up together in console. So yes, looks like the config file on different branches is the issue that needs to be addressed…