Umbraco Cloud
CMSHeartcoreDXPMarketplace
  • What is Umbraco Cloud?
  • Frequently asked questions
  • Security
    • Web Application Firewall
  • Sustainability Best Practices
  • Getting Started
    • Explore Umbraco Cloud
    • The Cloud Portal
      • Organizations
      • Sustainability Dashboard
    • Project Overview
    • Environments
    • Flexible Environments
    • Baselines
      • Baseline Merge Conflicts
      • Break Reference between Baseline and Child Project
      • Handling configuration files
      • Pushing Upgrades to a Child Project
    • Plans
    • Migrate to Umbraco Cloud
    • Repositories in a Cloud Project
    • Best Practice for Working in Teams
    • Migrate between regions
  • Set up
    • Ready to Set Up Your Project?
    • Working with a Local Clone
      • Legacy Umbraco Visual Studio Setup
    • Manage Environments
    • Project Settings
      • Managing Transport Security
      • CDN Caching and Optimizations
      • Dedicated Resources
      • Upgrade your Plan
      • Public Access
      • Managing Hostnames
        • New Certificate Authority for custom hostnames
        • Rewrite rules
        • Custom Certificates
      • Management API Security
      • Umbraco CI/CD Flow
        • Cloud API For CI/CD Flow
        • Configuring a CI/CD pipeline
          • Azure DevOps
          • GitHub Actions
          • Advanced Setup: Deploy to multiple targets
          • Migrate from V1 to V2
          • Deployment Artifact best practice
        • Troubleshooting
        • Known Limitations and Considerations
      • External Services
      • Usage
        • Bandwidth
      • Availability and Performance
      • Hostname Monitoring
      • Team Members
        • Technical Contact
      • Secrets Management
      • Project History
    • Private NuGet Feed on Umbraco Cloud
    • Going Live
    • Media
    • External Login Providers
    • Azure Blob Storage
      • Connect to Azure Storage Explorer to upload files manually
      • Connect and Upload Files Programmatically to Azure Blob Storage
    • Users
    • Multi-Factor Authentication
    • Application Insights
    • Config Transforms
    • SMTP Settings
    • Payments
    • Power Tools (Kudu)
      • View the Files on your Cloud Environments
      • Generate UDA files
      • Manually run Extractions on your Cloud Environments
  • Deployments
    • Deployment
    • Deploying between environments
    • Transferring Content, Media, Members, and Forms
    • Deploying Deletions
    • Deployment Webhook
    • Deploying Changes
    • Umbraco Forms on Cloud
    • Deploy Dashboard
    • Hotfixes
      • Apply hotfix by manually moving files
      • Apply hotfix by using Git
    • Restoring Content
      • Partial Restores
  • Databases
    • Keep Your Data Secure and Accessible
    • Working with databases
    • Database backups
    • Database
      • Connecting to the Database on Mac
    • Working with a Cloud database locally
  • Product Upgrades
    • Stay Up to Date with Umbraco Cloud
    • Product Upgrades
    • Major Upgrades
    • Minor Upgrades
    • Version Specific Upgrades
      • Migrate from Umbraco 8 to the latest version
      • Migrate from Umbraco 7 to Umbraco 8 on Umbraco Cloud
    • Upgrade your projects manually
      • Manual upgrade of Umbraco CMS
      • Manual upgrade of Umbraco Deploy
    • Dependencies on Umbraco Cloud
  • Troubleshooting
    • Resolve Issues Quickly and Efficiently
    • Troubleshooting FAQ
    • Log files
    • The Umbraco Backoffice
    • The Frontend
    • The Umbraco Cloud Portal
    • Site Performance checklist
    • Troubleshooting deployments
      • Extraction error: Config transforms failing
      • Extraction error: Data Type collisions
      • Dependency Exception
      • Merge Conflicts on Flexible Environments
      • Troubleshooting deployments failing with no error message
      • Troubleshooting duplicate dictionary items
      • Troubleshooting language mismatches
      • Path too long Exception
      • Schema Mismatches
      • How to resolve collision errors
      • Extraction error: "Type not found! "
    • Cloud Errors
  • Release Notes
    • Overview 2025
      • June 2025
      • May 2025
      • April 2025
      • March 2025
      • February 2025
      • January 2025
    • Overview 2024
      • December 2024
      • November 2024
      • October 2024
      • September 2024
      • August 2024
      • July 2024
      • May 2024
      • April 2024
      • March 2024
      • February 2024
      • January 2024
    • Overview 2023
      • December 2023
      • October 2023
      • September 2023
      • August 2023
      • June 2023
      • May 2023
      • April 2023
      • March 2023
      • February 2023
      • January 2023
    • Overview 2022
      • December 2022
      • November 2022
      • September 2022
      • August 2022
      • June 2022
      • May 2022
      • April 2022
      • March 2022
      • February 2022
      • January 2022
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
Export as PDF
  1. Set up
  2. Project Settings
  3. Umbraco CI/CD Flow
  4. Configuring a CI/CD pipeline

Advanced Setup: Deploy to multiple targets

In this example, you will learn how to target deployments to more than one environment.

The sample will enable you to work on two different branches, where each branch will deploy to a different environment.

With the CI/CD flow, you can trigger deployments to multiple environments at the same time.

If there is already a deployment in progress to a named environment, it will not be possible to trigger another until the first is done.

Replace the azure-release-pipeline.yaml with the one called azure-release-pipeline-more-targets.yaml. It's okay to rename azure-release-pipeline-more-targets.yaml.

Its locations in the sample scripts are:

  • Bash: /V2/bash/azuredevops/advanced

  • PowerShell: /V2/powershell/azuredevops/advanced

Make sure you don't have multiple YAML files that contain triggers (unless you designed your pipeline's workflow that way).

Now you need the aliases of the environments you want to target.

Insert the aliases into the placeholders in azure-release-pipeline-more-targets.yaml, the values you need to replace are:

  • ##Your target environment alias here##

  • ##Your other target environment alias here##

Remember to fix the projectId placeholder if you haven't already: ##Your project ID here##

Next, look at the triggers for the pipeline:

# Trigger when committing to main or flexible branch 
trigger:
  batch: true
  branches:
    include:
      - main
      - flexible

Here, you can change when a deployment is triggered based on which branch is pushed to.

The pipeline needs to resolve the target based on the triggering branch, which is done in the following code.

stages:
  # resolve which environment to deploy to based on triggering branch
  - stage: resolveTarget
    displayName: Resolve Target Environment
    jobs:
      - job: setTargetEnvironment
        steps:
          - script: |
              echo "Triggering branch: $(Build.SourceBranchName)"
              if [ "$(Build.SourceBranchName)" = "main" ]; then
                echo "Target is: $(targetEnvironmentAlias)"
                echo "##vso[task.setvariable variable=targetEnvironment;isOutput=true]$(targetEnvironmentAlias)"
              elif [ "$(Build.SourceBranchName)" = "flexible" ]; then
                echo "Target is: $(flexibleTargetEnvironmentAlias)"
                echo "##vso[task.setvariable variable=targetEnvironment;isOutput=true]$(flexibleTargetEnvironmentAlias)"
              else
                echo "no target environment defined for branch: $(Build.SourceBranchName)"
                exit 1
              fi
            name: setTargetEnvironmentValue

The triggering branch is evaluated in the statement if [ "$(Build.SourceBranchName)" = "main" ]; then or elif [ "$(Build.SourceBranchName)" = "flexible" ]; then.

The code will write which alias is targeted and write a pipeline variable (targetEnvironment). This variable is then used by later steps.

When updating the triggering branch names, it must be updated in the two mentioned places: In the trigger and in the script.

Replace the main.yml with the one called main-more-targets.yml. It's okay to rename main-more-targets.yml.

Its locations in the sample scripts are:

  • Bash: /V2/bash/github/advanced

  • PowerShell: /V2/powershell/github/advanced

Make sure you don't have multiple YAML files that contain triggers (unless you designed your pipeline's workflow that way).

Now you need the aliases of the environments you want to target.

  • Now go to the repository in GitHub, and click on the Settings section.

  • Expand secrets and variables in the left-hand menu titled Security and click on Actions.

  • Now go to the Variables tab

  • Add a repository variable called FLEXIBLE_ENVIRONMENT_ALIAS and enter the environment alias you selected earlier.

If you followed the GitHub guide you should already have a variable called TARGET_ENVIRONMENT_ALIAS.

Next, look at the triggers for the pipeline:

# Trigger when committing to main branch
on:
  push:
    branches:
      - main
      - flexible
  workflow_dispatch: # Allow manual triggering of the workflow

Here you can change when a deployment is trigger based on which branch is pushed to.

The pipeline needs to resolve the target based on the triggering branch, which is done in the following code.

jobs:
  # resolve which environment to deploy to based on triggering branch
  set-env:
    runs-on: ubuntu-latest
    outputs:
      targetEnvironmentAlias: ${{ steps.set.outputs.targetEnvironmentAlias }}
    steps:
      - name: Resolve Target Environment
        id: set
        run: |
          echo "Triggering branch: ${{ github.ref_name }}"
          if [[ "${{ github.ref_name }}" == "main" ]]; then
            echo "Target is: $leftmostMainline"
            echo "targetEnvironmentAlias=$leftmostMainline" >> $GITHUB_OUTPUT
          elif [ "${{ github.ref_name }}" = "flexible" ]; then
            echo "Target is: $flexible"
            echo "targetEnvironmentAlias=$flexible" >> $GITHUB_OUTPUT
          else
            echo "no target environment defined for branch: $(Build.SourceBranchName)"
            exit 1
          fi
        env:
          leftmostMainline: ${{ vars.TARGET_ENVIRONMENT_ALIAS}}
          flexible: ${{ vars.FLEXIBLE_ENVIRONMENT_ALIAS }}

The triggering branch is evaluated in the statement if [[ "${{ github.ref_name }}" == "main" ]]; then or elif [ "${{ github.ref_name }}" = "flexible" ]; then. The code will write which alias is targeted and write a pipeline variable (targetEnvironmentAlias). This variable is then used by later jobs.

When updating the triggering branch names, it must be updated in the two mentioned places: In the trigger and in the script.

PreviousGitHub ActionsNextMigrate from V1 to V2

Last updated 6 hours ago

Was this helpful?