Can't deploy changes to GitHub automatically on non-master branch

I have a dev Realm app that I have setup to automatically deploy to the dev branch of my GitHub repo. However, changes only seem to occur uni-directionally: from GitHub to MongoDB Realm, but not the other way around. If I make changes using the UI (e.g. editing the schema in Realm), I get the following history in the Deployment tab, and no change are pushed to my branch on GitHub.

Screenshot 2021-10-09 at 21.03.49

Note: It seems to work when deploying to a master/main branch but not to a dev branch.

Am I doing anything wrong? I thought that non-master branches were now accepted for automatic deployment?

Many thanks in advance!

Hi @Laekipia,

From my understanding, the Github deployment is unidirectional: Github => Realm app.
If it was bi-directional, they would both trigger each other indefinitely I guess and that would create an infinite loop.

If you want to modify your app also in the Github UI, then you must export your app manually to Github when you are done and create the commit yourself - which will redeploy your app with - hopefully - the same content.

You can choose the branch to sync from in the step 3:

You can retrieve the command lines to export your realm app to Github from the bottom of the Deployment > Configuration tab.

They should look something like this:

realm-cli pull --remote=community-test-irazb
mv community-test/* . && rm -r community-test
git add .
git commit
git push origin YOUR-BRANCH

Cheers,
Maxime.

Hi Maxime,
Thanks for your reply. I thought it would be uni-directional (for the reasons you mentioned) but it isn’t for the master branch (it just seems to be so for the dev branch only).

Here is an example when I configure my realm app to have automatic deployement to/from my master branch on GitHub.

  1. I make changes to the schema using the UI

  2. I deploy the draft changes and get the following message:

  3. I press ‘Deploy and Push to GitHub’.

  4. Under the deployment history tab, I then see the following:

  5. In my GitHub repo, I see the changes that have been pushed from Mongodb-realm itself

So if I understand correctly, the deployments can take place in both directions (at least for the master branch). Why does this not work for the dev branch then?

Cheers!

Wait…

There is a Deploy and Push to GitHub button now!?

image

Well, I learned something today :sweat_smile: !
Thank you!

Now… Well I guess I have to test this a bit more to answer your question :sweat_smile: !

Maybe @Lauren_Schaefer knows more about this feature. She worked a lot with this feature at some point but I don’t know if this new shinny button was already in the game or not.

Back to work… :smiley:

Just so I understand correctly what you are trying to do:

  • You have 2 Realm App:
    • SuperApp_Dev
    • SuperApp_Prod
  • They are both versioned in the same GitHub repo on 2 different branches: dev and master respectively.

You want bi-direction Realm UI <=> GitHub to work on both Realm App / branches.
Is this correct?

1 Like

Did you see this doc?

Humm

OK… Sooo.
I tried to create a new Realm App called RealmAppDeployTest_PROD linked to a brand new GitHub repo.
So far, so good. The code was sent from Realm UI => GitHub.
I also created a couple of functions which resulted in a couple of commits automatically added in my master branch.

But now, if I want to create a new Realm App RealmAppDeployTest_DEV, I guess this wouldn’t be an issue to create this Realm App on a new dev branch in my repo…
BUT
The problem is that these 2 branches are now completely different and pointing to different applications. For example, the realm_config.json file points to my PROD app and its bro file in the dev branch would point to the DEV app… Meaning that I can’t merde the dev branch in the master branch anymore without overwriting that file that shouldn’t be overwritten.
Same for the data sources as you probably want to keep your PROD running on your PROD Atlas cluster and the DEV on the DEV cluster.

Sooo… Maybe there is a trick that I’m missing with the environments but a direct git merge or rebase between dev and master doesn’t sound like a good idea for me so far.

Can you explain your plan/target if any?

Oooooh! I heard rumors this feature was coming, but I haven’t played with it yet.

1 Like

Hi Maxime, thanks for your detailed answer!

You’re bang on regarding the setup I was aiming for. I’ve also encountered the merging issue you’re mentioning but was hoping a simple .gitignore would prevent the realm_config.json file from being merged. There are some other files I’d like to not merge, like the sync folder (so that the realmApp_DEV can have Sync’s developer mode ON while the realmApp_PROD doesn’t).

My reason for wanting to do this is as follows: my app is in production and I want to make a bunch of changes to the schema safely without affecting realmApp_PROD. So I created the realmApp_DEV that my client app syncs to when I’m in dev. When I’m ready to push both the new client code and the new realmApp schema to production, I’d like to simply have to do a GitHub merge from dev branch to prod branch and that would automatically bring my schema changes to prod.

So technically, although the deployment to GitHub is bi-directional, I’d only use the functionality in one direction for each environment like so:

  1. realmApp_DEV changes deployed to GitHub dev branch
  2. GitHub prod branch deployed to realmApp_PROD.

The issue I have is that step 1 doesn’t work (presumably because my GitHub dev branch is not the master branch). Although I’ve read somewhere that it was now possible to deploy to a non-master branch on GitHub.