Configuring the staging branch

Create a staging environment and publishing workflow in CloudCannon.

The staging branch is where you can make edits and preview your changes before they go live.

Creating a staging site#

You'll need to create a new branch from production, push it to your Git provider, and connect it to a new CloudCannon site.

You can do this all at once in CloudCannon, through the site creation menu!

  • Navigate to Sites in the sidebar.
  • Click the Add new site button, and choose Build with your own files in the menu that appears.
  • Select your Git repo and choose Create a new branch. Select production as your source branch, and choose a name for your new branch (in this guide, we'll call it staging).
  • Continue through the steps of syncing and building the new site.

Set up publishing#

"Publishing" is the term CloudCannon uses for merging one branch into another. For more details, read our documentation on publishing.

Navigate to your new staging site, and open the Site Settings. You'll see a section called "Publishing".

A label in the Publishing menu explains that you must have at least two branches on your repository in order to enable publishing workflows on your site.

Here, you can choose a branch to merge into. Select the production branch.

You will also need to choose a Publish Mode. This simply means deciding whether you want to merge directly from CloudCannon, or to create a Pull Request before each merge.

Either way, you will see a new Publish button appears in the site sidebar, underneath the Save button. Click this button to review your pending changes and merge them into production.

Merging via Pull Request#

Note: GitLab uses the terminology Merge Request for this action; these will display as Pull Requests in CloudCannon.

If you have selected Pull Request as your Publish Mode, you will be able to issue pull requests from CloudCannon. Enter a title and description and click Create Pull Request. You can see a list of the pending commits on the right.

Pending pull requests will be listed in this menu. You can click Merge to merge the branch, or Close to close the pull request. If you have set any branch protection rules with your Git provider which would be violated by this merge, the merge will fail and the pull request will stay open.

Merging directly#

If you want to be able to merge staging into production directly from CloudCannon, select Merge as the Publish Mode. In this case, the Publish menu will simply show a Merge button, with no intermediate steps.

What's next?#

You now have a staging/production workflow! You can preview your in-progress changes on the testing domain for your staging site, and merge them into your user-facing production site only once you are ready.

The next step of the guide will explore ways to extend this workflow for more use cases. This is optional and may be useful depending on your particular project.

Open in a new tab