CD for hosting while using UI for Realm

Hi,

I setup Realm hosting using a git repository and this successfully replaces files on the hosting service when I make a change. However, this also seems to undo changes I made in the UI for non-hosting files.

I don’t really want to go back to picking files one-by-one in the UI for front-end deploys. I want it to be automated CD. Is there any way to get changes made in the Realm UI to sync back to github? It seems like a one-way binding.

Is there a way to have both worlds? I want to use the Realm web UI + automate Front-end deploys.

Hey Travis,

Have you considered using the automated GitHub deploys for both hosted files and other changes to your Realm app (like functions, triggers, etc)? More information is available at https://docs.mongodb.com/realm/deploy/deploy-automatically-with-github.

I’ve successfully used this for my project and found it really helpful. All of the details of how I setup the auto deploys as well as a video demo are included in the project readme: https://github.com/mongodb-developer/SocialStats.

Hey thanks @Lauren_Schaefer !

Yes, I’m using github deploys for the hosting - and that’s where I ran into trouble.
I build+copy my hosted files over from the front-end app into the hosting/files directory, commit and push and it auto-deploys.

The problem I run into is that it overrides the changes (like say, a login or schema/graphql change) that I made in the UI, reverting them back to previous settings.
Those changes don’t seem to get back to github. Should they? Do you think I set something up incorrectly?

I am going to take a look at that project you referenced though. It looks super thorough and I’d love to get a 4-stage pipeline going. Thanks again!

1 Like

I think that what you’re describing may be expected. Let me ask around, and I’ll get back to you.

@Travis_N_A I was able to replicate the issue you’re hitting. I talked with the team, and this is a bug. We’ve filed a ticket around the GraphQL changes being lost.

In general, changes made in the UI that have been deployed should not be lost when you push changes to your GitHub repo. The changes made in the UI will not be pushed to your GitHub repo.

1 Like

Thanks @Lauren_Schaefer - is the bug list somewhere online? I just ran into the issue again when re-deploying and would like to track it so I know when its resolved.

Also took a look at your example repo/video and learned a lot, thanks! It’ll be a while before I can setup that kind of pipeline but eventually…

Hi @Travis_N_A! Sorry for the significant delay in my response! I was out a week for Thanksgiving and then a week for illness.

I checked the ticket, and it’s in progress. I can’t find an external version of the ticket. I’ve asked, and I’ll let you know if I find one.

I’m glad you found the repo and video helpful! Hopefully, the repo will help you get your pipeline setup more quickly!

Hey @Travis_N_A - I spoke with an engineer on the team today. He made a fix related to this problem that he thought would fix the issue. It didn’t fix the issue I was hitting, but maybe it will fix yours.

The issue I was hitting was more a misunderstanding of how the system works. So, below is what I learned.

Custom resolvers are stored as code in the GitHub repo. When you make changes in the web ui, those changes are not stored in the GitHub repo. Whenever you push to your repo and trigger an auto-deploy, any changes not stored in the GitHub repo (like custom resolvers) get tossed away. So once you start using auto-deploys you need to either:

  1. Make all of your changes in your code OR
  2. Make your changes in the web IDE, export the changes from the web IDE (you can use a command like
    realm-cli export --app-id=yourappid --for-source-control --include-hosting
    mv yourdirectory/* . && rm -r yourdirectory
    The Deploy page has the commands listed for you), and then push the changes to your GitHub repo

I’m passing feedback on to the product manager that we need some warnings in the web ui that your changes will be lost in your next deploy, or, even better, have the option of pushing the changes to your associated GitHub repo.

2 Likes

Thank you for trying to help with this. Sadly this didn’t work.

In this case I did what you said, exporting to a new directory:

realm-cli export --app-id=my-appid --for-source-control --include-hosting

Then in my original repo for realm I:

git checkout -b changes-from-ui
cp -a ../new-realm-export/* .   # over-write files with the new download */

git checkout hosting/*     # I'm replacing these with a new front-end version in the next step

git status at this point showed that there were changes to config.json which seemed reasonable and to 2 files in services/mongodb-atlas/rules/. There were also new files in functions and values.

  • functions makes sense, I definitely modified that.
  • values, I’m very confused by since it has the same directory structure as the existing repo. A quick scan of file-sizes tells me that it’s most likely a complete duplicate of the parent directory. (Note I did the export twice to confirm)

Anyway, assuming that all of that is correct I proceeded:

git add .
git commit -m "import ui changes from realm"

Then I replaced the hosting directory with the latest version of my front-end app. That results in changes to my hosting directory ONLY, which I also commit.

Then I pushed it all to master.

The Deploy tab showed that it failed with the message “Failed: No download link found for values/auth_providers”. Since only realm-UI changes were made there I expect that it should have JUST worked.


I performed the above steps twice and got the same error message both times. At this point, I’m no longer able to deploy front-end changes.

If I could make one suggestion it would be to allow using a separate front-end repo.

Out of frustration I tried again and I was able to deploy with just the front-end changes ignoring all of the above recommendations. But it once again overrode the significant number of changes I’d made in the Realm UI and as a result broke the graphql queries the front-end was using. That was to be expected. However…

I tried just pushing the downloaded copy (from realm-cli) but that hits the same Failed: No download link found for values/auth_providers deploy error. If I could give any feedback at this point, it is that the code that realm-cli exports with the --for-source-control flag really must be deployable and it is not.

I thought I was dead in the water here - unable to deploy the previous back-end and unable to develop the new front-end since it required changes that had been made in that back-end. But I have found a way forward. This time I did the same steps as above but I added a step:

rm -fr values

This makes it deployable. Again I want to emphasize that realm-cli --for-source-control really should result in deployable code and it does not.

Obviously I’m a bit frustrated at this point, please forgive me if I haven’t been as cordial as usual.

Hey @Travis_N_A,

Sorry - I didn’t get a notification about your reply. (I’m going to dig into the settings to see if I can get a notification when someone replies to a post I’ve commented in without explicitly tagging me.)

And sorry this has been so frustrating for you!!! It sounds like you’ve made a way forward. Are you still stuck on a piece of this?

I’ll pass on your feedback to the product manager. I spoke with him last week about the issues we were seeing. He showed me the plan for the future, and the plan looks good. Positive changes are coming. This will get easier.

1 Like