You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: umbraco-cloud/set-up/project-settings/umbraco-cicd/samplecicdpipeline/advanced-multiple-targets.md
+32-22Lines changed: 32 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
# Deploy to multiple targets
2
-
In this example we will show how to target deployments to more than one environment.
3
2
4
-
The sample will make it possible for you to work on two different branches where each branch will deploy to a different environment.
3
+
In this example, you will learn how to target deployments to more than one environment.
4
+
5
+
The sample will enable you to work on two different branches, where each branch will deploy to a different environment.
5
6
6
7
{% hint style="info" %}
7
-
With the CI/CD flow you can trigger deployments to multiple environments at the same time.
8
+
With the CI/CD flow, you can trigger deployments to multiple environments at the same time.
8
9
9
10
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.
10
11
{% endhint %}
@@ -13,20 +14,24 @@ If there is already a deployment in progress to a named environment, it will not
13
14
{% tab title="Azure DevOps" %}
14
15
15
16
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`.
16
-
It's locations in the samples scripts are:
17
-
- For bash: `/V2/bash/azuredevops/advanded`
18
-
- For PowerShell: `/V2/powershell/azuredevops/advanded`
19
17
20
-
Make sure you don't have multiple yaml files which contains triggers (unless you designed your pipelines workflow that way).
Make sure you don't have multiple YAML files that contain triggers (unless you designed your pipeline's workflow that way).
21
24
22
-
Now you need the aliases of the environments you want to target.
25
+
Now you need the aliases of the environments you want to target.
23
26
24
-
Insert the aliases into the placeholders in `azure-release-pipeline-more-targets.yaml`, the values you need to replace are:
27
+
Insert the aliases into the placeholders in `azure-release-pipeline-more-targets.yaml`, the values you need to replace are:
28
+
25
29
-`##Your target environment alias here##`
26
30
-`##Your other target environment alias here##`
27
-
- Also remember to fix the projectId placeholder if you haven't already: `##Your project Id here##`
31
+
32
+
Remember to fix the projectId placeholder if you haven't already: `##Your project ID here##`
28
33
29
-
Next look at the triggers for the pipeline:
34
+
Next, look at the triggers for the pipeline:
30
35
31
36
```yml
32
37
# Trigger when committing to main or flexible branch
@@ -38,9 +43,10 @@ trigger:
38
43
- flexible
39
44
```
40
45
41
-
Here you can change when a deployment is trigger based on which branch is pushed to.
46
+
Here, you can change when a deployment is triggered based on which branch is pushed to.
42
47
43
48
The pipeline needs to resolve the target based on the triggering branch, which is done in the following code.
49
+
44
50
```yml
45
51
stages:
46
52
# resolve which environment to deploy to based on triggering branch
@@ -65,30 +71,33 @@ stages:
65
71
```
66
72
67
73
The triggering branch is evaluated in the statement `if [ "$(Build.SourceBranchName)" = "main" ]; then` or `elif [ "$(Build.SourceBranchName)" = "flexible" ]; then`.
68
-
The code will write which alias is targeted and write a pipeline variable (`targetEnvironment`). This variable is then used by later steps.
69
74
70
-
Note: When updating the triggering branch names it must be updated in the two mentioned places: In the trigger and in the script.
75
+
The code will write which alias is targeted and write a pipeline variable (`targetEnvironment`). This variable is then used by later steps.
71
76
77
+
When updating the triggering branch names, it must be updated in the two mentioned places: In the trigger and in the script.
72
78
73
79
{% endtab %}
74
80
{% tab title="GitHub Actions" %}
75
81
76
82
Replace the `main.yml` with the one called `main-more-targets.yml`. It's okay to rename `main-more-targets.yml`.
77
-
It's locations in the samples scripts are:
78
-
- For bash: `/V2/bash/github/advanced`
79
-
- For PowerShell: `/V2/powershell/github/advanced`
80
83
81
-
Make sure you don't have multiple yaml files which contains triggers (unless you designed your pipelines workflow that way).
84
+
Its locations in the sample scripts are:
85
+
86
+
- Bash: `/V2/bash/github/advanced`
87
+
- PowerShell: `/V2/powershell/github/advanced`
88
+
89
+
Make sure you don't have multiple YAML files that contain triggers (unless you designed your pipeline's workflow that way).
90
+
91
+
Now you need the aliases of the environments you want to target.
82
92
83
-
Now you need the aliases of the environments you want to target.
84
93
* Now go to the repository in GitHub, and click on the Settings section.
85
94
* Expand secrets and variables in the left-hand menu titled `Security` and click on `Actions`.
86
95
* Now go to the **Variables** tab
87
96
* Add a `repository variable` called `FLEXIBLE_ENVIRONMENT_ALIAS` and enter the environment alias you selected earlier.
88
97
89
98
If you followed the [GitHub guide](github-actions.md) you should already have a variable called `TARGET_ENVIRONMENT_ALIAS`.
90
99
91
-
Next look at the triggers for the pipeline:
100
+
Next, look at the triggers for the pipeline:
92
101
93
102
```yml
94
103
# Trigger when committing to main branch
@@ -103,6 +112,7 @@ on:
103
112
Here you can change when a deployment is trigger based on which branch is pushed to.
104
113
105
114
The pipeline needs to resolve the target based on the triggering branch, which is done in the following code.
115
+
106
116
```yml
107
117
jobs:
108
118
# resolve which environment to deploy to based on triggering branch
@@ -133,7 +143,7 @@ jobs:
133
143
The triggering branch is evaluated in the statement `if [[ "${{ github.ref_name }}" == "main" ]]; then` or `elif [ "${{ github.ref_name }}" = "flexible" ]; then`.
134
144
The code will write which alias is targeted and write a pipeline variable (`targetEnvironmentAlias`). This variable is then used by later jobs.
135
145
136
-
Note: When updating the triggering branch names it must be updated in the two mentioned places: In the trigger and in the script.
146
+
When updating the triggering branch names, it must be updated in the two mentioned places: In the trigger and in the script.
0 commit comments