Syncing to GitHub
You can sync your Modelbit git repo to a repo in your company's GitHub account. This is especially valuable for using your GitHub-based code review, CI/CD and Pull Request workflows on your Modelbit deployments.
This workflow requires you to have admin permissions within your GitHub account.
Create a new, empty Git repository for use with Modelbit. The GitHub integration will not complete if the repo already has files.
Adding your GitHub repo URL to Modelbit
First, make a new GitHub repo inside your GitHub account.
Once created, from the "Code" tab of your GitHub repo, click the green "Code" button and copy out the URL. The URL will look like git@github.com:your-organization/repo-name.
Head back to Modelbit:
- In
Settings, open theGit Settingspage. - Click the
GitHubbutton, then clickNext. - Paste in the URL of your GitHub repo and click
Next.
Before heading back to GitHub, copy the Deploy Key. This Deploy Key is Modelbit's public key for pushing and pulling your Git repo, just like a user's public key. It is not a secret.
Adding your Modelbit deploy key to GitHub
Open your repo in GitHub, then:
- Click the
Settingstab of your repo. - On the left hand side, click
Deploy keys. - On the upper right of this page, click
Add deploy key. - Paste the Modelbit deploy key. Give it a memorable name like
Modelbit integration.
Make sure to check the Allow write access box and click save.
You must check the Allow write access box in order for Modelbit to push changes to this repository.
Head back to Modelbit, click Next, and Modelbit will test the connection to GitHub. If the Deploy Key has been set with write access and no branch protection rules prevent Modelbit from syncing with the repo, you're all set.
Now Modelbit will sync to your GitHub repo, allowing you to use GitHub Pull Requests for merges, and all your GitHub-based tools for CI/CD, code review and more!
Do not use git clone with this repository. Always use modelbit clone. The modelbit clone command will clone your repo and configure it to work with Modelbit.
Branch protection rules
You may enable branch protection rules to facilitate advanced git workflows with your team. However, you must allow the Modelbit integration to bypass the branch protection rules.
To allow Modelbit to continue to sync with your GitHub repository, ensure that Deploy Keys are allowed to bypass the branch protection rules:
GitHub Webhooks
To ensure the quickest sync between GitHub and Modelbit, configure GitHub to notify Modelbit of changes using GitHub webhooks.
You'll find Modelbit's Webhook URL and Secret in the Git Settings page.
In GitHub, go to your repository's settings page and:
- Click Webhooks, then
Add Webhook - Paste Modelbit's
Webhook URLinto thePayload URLfield - Set
Content Typetoapplication/json - Paste Modelbit's
Webhook Secretinto theSecretfield - Click
Add Webhook
Make sure to set the Content Type to application/json. The webhook won't work otherwise.
The next time you push changes to GitHub, Modelbit will be notified and immediately sync the changes.