Deploy code changes

Overview

Sitefinity SaaS is configured in a CI/CD setup, in accordance with development best practices. 

Code deployment is the process that validates and pushes changes to the .NET Core Renderer project. It is done through a CI/CD pipeline, which consists of tasks and conditions, ensuring the successful pushing of new code to the corresponding environment.

Develop code locally

By default, the deployment workflow is in line with the software development practice of Continuous Delivery (CD) for deploying new changes across environments. During this process, the deployment package is prepared from the main branch of the repository and is then subsequently deployed to each environment, following an approval/verification/testing step until reaching Production. By following these best practices, committing your changes directly to the main branch is restricted. Instead, all code development must be done in a dedicated feature branch, which you create from main branch, and then you merge your changes into main via pull request from the feature branch.

This flow can be customized according to the customer's needs. For example, there can be a different branch or set of branches configured for each environment. The process of merging pull requests between branches will trigger a build and deploy to the environment of the target branch. In addition, you can configure deployments to any environment to be triggered manually.

Create a feature branch

Creating a new feature branch for development follows the standard Git development workflow. If you have cloned your .NET Core Renderer project in Visual Studio, perform the following:

  1. Clone the main branch to begin local development. Follow the procedure Set up the project for local development » Set up the .NET Core Renderer project code locally.
  2. From your Visual Studio Team Explorer, locate the main branch, right click on it and select New Local Branch From...
  3. 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.

Deploy your code

Once your feature branch with the desired changes has been synchronized to Sitefinity SaaS, you are able to proceed by merging these changes to the project main branch and deploy them to the Staging environment.

Create a pull request to push your code to the main branch

Proceed by following these steps:

  1. Log in to your Sitefinity SaaS Management Portal.
  2. Navigate to Repos » Pull requests and click New pull request.
  3. From the source branch selection dropdown, select the feature branch you want to merge changes from. From the target branch selection dropdown, select main.
  4. Fill in the pull request details and proceed by clicking Create.

Approve and merge pull requests

Each pull request must be approved before merging the changes to the main 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:

  1. In your Sitefinity SaaS Management Portal, navigate to Repos » Pull requests and click the Active tab.
  2. Click the name of desired pull request from the list. 
  3. On the next screen, you can review the pull request and approve it by clicking Approve.

As a result, all policy requirements are marked as met and an automated CI build is triggered to test the changes against the main branch. To complete merging the changes, click Complete (located next to the Approve button). 

NOTE: Once the merge is successfully completed, the feature branch is 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 main branch and a deployment is triggered to apply the changes on the corresponding Staging environment. You can browse the Staging environment where the changes have been deployed 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, deploying to Production requires approval from a user with Promote to Production role. You can view deployments pending approval to Production, and promote them by following these steps: 
  1. In your Sitefinity SaaS Management Portal, navigate to Pipelines » All.
  2. Select DotNetCoreRenderer.CI.CD.
  3. Locate the Run that is pending approval to Production and open it.
  4. Click Review next to the message 1 approval needs your review before this run can continue to Production
  5. In the dialog box that opens, click Approve or Reject.

Customize CI stage in CI/CD pipeline for .NET Core Renderer

To facilitate the needs of customizing the CI/CD process, Sitefinity SaaS offers a mechanism for extending the existing CI/CD pipeline and include custom tasks for the following events: 
  • Pre-build tasks in CI stage
  • Post-build tasks in CI stage

Follow these steps:

  1. Open the CICD.yaml file located in the repository of the .NET Core Renderer project.
  2. Locate the parameters element for the extended CICDDotNetCoreRendererTemplate.yaml.
  3. Add a new parameter of type stepList called preBuildSteps or postBuildSteps, and add tasks using the standard YAML task/step syntax.

The example below demonstrates custom pre-build steps for adding custom NuGet sources and post-build steps for running unit tests:

Was this article helpful?