Deploy code changes

Overview

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

Code deployment is the process that validates and pushes changes to your 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 ASP.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 (using ASP.NET Core Renderer) » Set up the ASP.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.

If you have cloned your Next.js Renderer project in Visual Code, perform the following:

  1. Clone the main branch to begin local development. Follow the procedure Set up the project for local development (using Next.js Renderer) » Set up the Next.js Renderer project code locally.
  2. From your Visual Code, locate the main branch, left click on it and select Create new 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. For ASP.NET Core Renderer: Select DotNetCoreRenderer.CI.CD.
    For Next.js Renderer: Select NextJsRenderer.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 your 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

Using ASP.NET Core Renderer

Follow these steps:

  1. Open the CICD.yaml file located in the repository of the ASP.NET Core Renderer project.
  2. Locate the parameters element for the extended CICDDotNetCoreRendererTemplateV2.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:

Using Next.js Renderer

Follow these steps:

  1. Open the CICD.yaml file located in the repository of the Next.js Renderer project.
  2. Locate the parameters element for the extended CICDNextJsRendererTemplateV2.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 using specific version of Node.js during build process:

Was this article helpful?