This article describes how to use integrate version control systems with the Moovweb SDK. (If you are still using Moovweb SDK 4.7 or earlier, please see the deprecated git push instructions below for deployment.)
When using Git with the Moovweb SDK, the best way to stay synchronized with the Moovweb Cloud is to write a deploy script that sets your
-deploy-id equal to the hash of the current commit you’re on.
This deploy script could be something as simple as:
moov deploy -deploy-id=`git rev-parse HEAD` <myAccount>/<myProject>
Or it could be a more complex script taking a variety of other factors into account.
In Moovweb 4.7 and earlier, Moovweb used Git pushes to deploy code to the Moovweb Cloud. This will still work for users with older versions of the Moovweb SDK, but if you are using Moovweb 5 or later, you should use the Moov Deploy instructions at the top of this page.
Moovweb still recommends using Git or any preferred version control system to manage your project code, but pushing with Git is no longer necessary for deployment. Git is a distributed version control system similar to Subversion (SVN) or Mercurial. You will have already downloaded and installed the latest version of Git as part of the download process. You can also configure your Git settings.
Verify your Git installation and configuration from the terminal:
git config -l
This will display your username, email, and any other settings you’ve configured.
Once you have generated a Moovweb project you can create a new Git code repository on GitHub. Add this code repo as another Git remote on your Moovweb project:
git remote add github email@example.com:<github_account_name>/<project_name>.git
You can also connect your Moovweb project to the GitHub repo via the settings page of your project:
Once added, Git commits on the project page will link to the corresponding commit in GitHub.
You should periodically commit and push your work to GitHub in order that your code is stored. You can also use GitHub to collaborate with other developers, review commit messages and track issues.
Then, to push your work to GitHub you would run:
git push github master
If you have an existing GitHub repo with your code, and you are using the Moovweb SDK version 4.7 or earlier, you can also easily add a new Moovweb remote repo, like so:
git remote add moovweb firstname.lastname@example.org:<moovweb_account_name>/<project_name>.git
And to push changes to this new Moovweb remote, run:
git push moovweb master
You will automatically trigger the build process. Keep in mind that if you are using Moovweb SDK version 5 or later, you should use the
moov deploy command instead of pushing with Git.
If you have Git submodules in your project, the build will fail. Please see our article on Submodules and Subtrees for more information.
For most production websites, you would have one code repository called origin and two Moovweb projects — staging and production.
You should have all these three (origin, staging, and production) as remotes to your local Git repo. Typically, origin will be your GitHub repo, the staging project will point to a hidden staging domain, while the production project will have the live domain m.example.com.
Here’s an example setup:
git remote -v
origin email@example.com:github_account/project_name.git (fetch) origin firstname.lastname@example.org:github_account/project_name.git (push) staging email@example.com:moovweb_account/project_staging.git (fetch) staging firstname.lastname@example.org:moovweb_account/project_staging.git (push) production email@example.com:moovweb_account/project_prod.git (fetch) production firstname.lastname@example.org:moovweb_account/project_prod.git (push)
Your deployment workflow can then be set up as: