6
6
#
7
7
# http://www.apache.org/licenses/LICENSE-2.0
8
8
9
- # Reusable workflow to perform update of CSI sidecars .
10
- name : CSI Sidecars Update
9
+ # Reusable workflow to perform update of CSM Versions .
10
+ name : CSM Versions Update
11
11
12
12
# Invocable as a reusable workflow
13
13
on :
14
14
workflow_call :
15
15
16
16
jobs :
17
- csi-sidecars -update :
17
+ csm-versions -update :
18
18
runs-on : ubuntu-latest
19
19
steps :
20
20
- name : Checkout code
21
21
uses : actions/checkout@v4
22
22
23
- - name : Get Latest CSI Sidecar Versions from dell/csm
23
+ - name : Get CSM Versions from dell/csm
24
24
id : vars
25
25
run : |
26
26
curl -s https://raw.githubusercontent.com/dell/csm/refs/heads/main/config/csm-versions.yaml > versions-content.txt
27
27
28
- # Parse out and save each csi sidecar version
28
+ # Parse out and save each needed CSM version
29
29
readarray -t lines < versions-content.txt
30
30
for line in "${lines[@]}"; do
31
31
name=$(echo $line | cut -d: -f1 | tr -d ' ')
@@ -45,11 +45,13 @@ jobs:
45
45
echo "health_monitor=$version" >> "$GITHUB_OUTPUT"
46
46
elif [[ $name == "csm-version" ]]; then
47
47
echo "csm=$version" >> "$GITHUB_OUTPUT"
48
+ elif [[ $name == "otel-collector" ]]; then
49
+ echo "otel_collector=$version" >> "$GITHUB_OUTPUT"
48
50
fi
49
51
50
52
done
51
53
52
- - name : CSM docs sidecar update
54
+ - name : CSM docs versions update
53
55
if : ${{ github.repository == 'dell/csm-docs' }}
54
56
env :
55
57
attacher : ${{ steps.vars.outputs.attacher }}
@@ -58,41 +60,50 @@ jobs:
58
60
resizer : ${{ steps.vars.outputs.resizer }}
59
61
registrar : ${{ steps.vars.outputs.registrar }}
60
62
health_monitor : ${{ steps.vars.outputs.health_monitor }}
63
+ otel_collector : ${{ steps.vars.outputs.otel_collector }}
61
64
csm : ${{ steps.vars.outputs.csm }}
62
65
run : |
63
- echo "We are updating csm docs..."
64
-
65
- declare -A sidecars
66
- sidecars[csi-attacher]=$attacher
67
- sidecars[csi-provisioner]=$provisioner
68
- sidecars[csi-snapshotter]=$snapshotter
69
- sidecars[csi-resizer]=$resizer
70
- sidecars[csi-node-driver-registrar]=$registrar
71
- sidecars[csi-external-health-monitor-controller]=$health_monitor
72
-
73
- update_shortcodes_sidecars() {
74
- for key in "${!sidecars[@]}"; do
66
+ declare -A latest_images
67
+ latest_images[csi-attacher]=$attacher
68
+ latest_images[csi-provisioner]=$provisioner
69
+ latest_images[csi-snapshotter]=$snapshotter
70
+ latest_images[csi-resizer]=$resizer
71
+ latest_images[csi-node-driver-registrar]=$registrar
72
+ latest_images[csi-external-health-monitor-controller]=$health_monitor
73
+ latest_images[opentelemetry-collector]=$otel_collector
74
+
75
+ # Global variables
76
+ updated_shortcodes=""
77
+ updated_installation_wizard=""
78
+
79
+ update_shortcodes() {
80
+ for key in "${!latest_images[@]}"; do
75
81
path="layouts/shortcodes/version-docs.html"
76
82
name=$(echo $key | tr '-' '_')
77
- version=${sidecars[$key]}
78
-
79
- echo "Updating $key to $version"
83
+ version=${latest_images[$key]}
80
84
81
- # Get the shortcode location for sidecar
82
- sidecar_shortcode=$(grep -r "\"$name.*\" -}}" $path)
85
+ # If no shortcode was found, we don't need to update it
86
+ if ! grep -q "\"$name.*\" -}}" $path; then
87
+ echo "No shortcode found for $key. Skipping."
88
+ continue
89
+ fi
83
90
84
- # Remove the version from the shortcode
85
- partial_shortcode=$(echo "$sidecar_shortcode" | sed -E 's/v[0-9]+\.[0-9]+\.[0-9]+//g')
91
+ old_shortcode=$(grep -r "\"$name.*\" -}}" $path)
86
92
87
- # Replace the version in the shortcode
88
- sed -i "s/${sidecar_shortcode}/${partial_shortcode}$version/g" $path
93
+ # If shortcode already contains the version, we don't need to update it
94
+ if [[ "$old_shortcode" == *"$version"* ]]; then
95
+ continue
96
+ fi
97
+
98
+ new_shortcode=$(echo $old_shortcode | sed "s/}}.*/}}$version/")
99
+
100
+ updated_shortcodes+="\t$key to $version\n"
101
+ sed -i "s|${old_shortcode}|${new_shortcode}|g" $path
89
102
done
90
103
}
91
104
92
- update_installation_wizard_sidecars() {
93
- # Get the latest CSM version
94
- echo "Latest CSM Version is $csm"
95
-
105
+ update_installation_wizard() {
106
+ echo "Starting installation wizard update..."
96
107
# Sanitize the CSM version
97
108
csm_version=$(echo $csm | tr -d 'v' | tr -d '\r')
98
109
@@ -105,25 +116,55 @@ jobs:
105
116
fi
106
117
107
118
for file in $wizard_files; do
108
- echo "Replaceing Sidecars in $file "
109
- for key in "${!sidecars [@]}"; do
119
+ updated_images=" "
120
+ for key in "${!latest_images [@]}"; do
110
121
# Retrieve the current version from the file of the sidecar.
111
122
old_version=$(grep -r -m 1 "$key:" $file | xargs)
112
123
if [ -z "$old_version" ]; then
113
124
continue
114
125
fi
115
126
116
- # Replace the old version with the new version.
117
- new_version=$(echo $old_version | sed "s/:v[^\"]*/:${sidecars[$key]}/")
127
+ # All instance of the image in a file either go "image:/value:" so we remove that to get the pure image.
128
+ old_version=$(echo $old_version | cut -d':' -f2- | tr -d ' ')
129
+ new_version=$(echo $old_version | sed "s/:.*/:${latest_images[$key]}/")
130
+
131
+ # If the version is the same, then we skip
132
+ if [ "$old_version" == "$new_version" ]; then
133
+ continue
134
+ fi
135
+
136
+ updated_images+="\t$new_version\n"
118
137
119
138
# Update the version in the file.
120
139
sed -i "s|${old_version}|${new_version}|g" $file
121
140
done
141
+
142
+ if [ -z "$updated_images" ]; then
143
+ continue
144
+ fi
145
+
146
+ updated_installation_wizard+="Updated $file with the following images:\n$updated_images\n"
122
147
done
123
148
}
124
149
125
- update_shortcodes_sidecars
126
- update_installation_wizard_sidecars
150
+ handle_results() {
151
+ if [ -z "$updated_shortcodes" ] && [ -z "$updated_installation_wizard" ]; then
152
+ echo "No changes were made. Skipping."
153
+ return
154
+ fi
155
+
156
+ if [ -n "$updated_shortcodes" ]; then
157
+ echo -e "Updated Shortcodes:\n$updated_shortcodes"
158
+ fi
159
+
160
+ if [ -n "$updated_installation_wizard" ]; then
161
+ echo -e "$updated_installation_wizard"
162
+ fi
163
+ }
164
+
165
+ update_shortcodes
166
+ update_installation_wizard
167
+ handle_results
127
168
128
169
- name : Remove versions content file
129
170
run : rm versions-content.txt
@@ -143,11 +184,11 @@ jobs:
143
184
uses : peter-evans/create-pull-request@v7
144
185
with :
145
186
token : ${{ steps.generate-token.outputs.token }}
146
- branch : " update-csi-sidecars "
147
- commit-message : " Update CSI sidecar versions to latest"
148
- title : " Update CSI sidecar versions to latest"
187
+ branch : " update-csm-versions-to-latest "
188
+ commit-message : " Update CSM versions to latest"
189
+ title : " Update CSM versions to latest"
149
190
body : |
150
- Automated update of CSI sidecar versions .
191
+ Automated update all CSI Sidecars and Third Party Libraries to their latest version .
151
192
152
193
Auto-generated by [common-github-actions](https://github.com/dell/common-github-actions)
153
194
sign-commits : true
0 commit comments