Deploy code changes to the Cloud
Sitefinity Cloud is configured in a CI/CD set up, in accordance to Sitefinity website development best practices and the Microsoft Azure services that are being used.
Code deployment is the process that validates and pushes new changes to the Sitefinity Cloud project deployment instances. It is done through a build pipeline, which consists of several tasks and conditions, ensuring the success of pushing new code to the corresponding deployment stage.
Develop code locally
By default, your Sitefinity Cloud project runs from the master branch on both Staging and Production environments. Following best practices, committing your changes directly to the master branch has been restricted. Instead, all code development must be done in a dedicated feature branch, which you create from master, and then merge your changes into master via pull request from the feature branch.
Create a feature branch
Creating a new feature branch for development follows the standard Git development workflow. For example, if you cloned your Sitefinity Cloud project solution in Visual Studio, follow these steps to create a feature branch:
- Clone the master branch to begin local development, following the Setting up the project code locally instruction from the Setup the project for development article.
- From your Visual Studio Team Explorer locate the master branch, right click on it and select the New Local Branch From... option
- Name your new branch and create it
As a result your feature branch for local development is created, and you can proceed with your project development.
Commit your changes and sync them to Sitefinity Cloud
When you are done with your changes you must commit them via the Visual Studio Team Explorer » Changes screen. This action commits your changes only to the local branch.
Once you are ready with your changes and want to deploy them to Sitefinity Cloud, use the Visual Studio Team Explorer » Sync screen to push your changes to Sitefinity Cloud. This operation will synchronize your new feature branch and the committed changes.
Deploy your code to the Staging environment
Once your feature branch with the desired changes has been synchronized to Sitefinity Cloud you are able to proceed by merging these changes to the project master branch and deploy them to the Staging environment.
Create a pull request to push your code to the master branch
Proceed by following these steps:
- Log in to your Sitefinity Cloud project Management Portal
- Navigate to Repos » Pull requests and click on the New pull request button
- From the source branch selection dropdown, select the feature branch you want to merge changes from. From the target branch selection dropdown, select master.
- Fill in the pull request details and proceed by clicking the Create button
Approve and merge pull requests
Each pull request must be approved before merging the changes to the master branch. By default, all users who are in the Contributors role can approve pull requests. To view pull requests, that are pending approval, and approve them follow these steps:
- In to your Sitefinity Cloud project Management Portal navigate to Repos » Pull requests and click on the Active tab
- Click on the name of desired pull request from the list
- From the screen that opens you can review the pull request and approve it by clicking the Approve button
As a result all policy requirements will be marked as met and an automated CI build is triggered to test the changes against the master branch. To complete merging the changes, click on the Complete button, located next to the Approve button.
NOTE: Once the merge is successfully completed, the feature branch will be automatically deleted, as it is no longer needed.
Approving a merge triggers an automated CI build and upon successful completion the changes are merged in the master branch used by the Staging environment. You can proceed by browsing the Staging environment to verify your newly deployed functionality is working as expected.
Promote your code to the production environment
Once you have verified your code works as expected on the Staging environment you can promote it to the Production environment. By default, each successful build to the Staging environment, requires approval from a user in the Contributors role before going to the Production environment. You can view builds pending approval to Production, and promote them by following these steps:
- In to your Sitefinity Cloud project Management Portal navigate to Pipelines » Releases
- Ensure the Quantum.CD (Production) pipeline is selected
- Select the Releases tab
- Locate the desired release that is pending approval for Production and click on the Production button
- On the next screen proceed with approving the build
As a result an automatic CD build is triggered and upon successful completion the code is deployed to the Production environment.
Validate the deployment success
To ensure transparency and traceability of the project’s deployments, more information about each pipeline’s releases and deployments, such as release and build version, branch, and queue date are available in the Deployment dashboard. For more information about Sitefinity Cloud dashboards see Dashboards. Alternatively, you can also trace the status of each build from the Pipelines » Builds screen of your Sitefinity Cloud Management Portal.
Automated rollback in case deployment fails
In case promoting a new package fails, an automatic rollback of the project and database is triggered and handled by Sitefinity Cloud. During the rollback, the project files and database are restored to their last successfully running version.