From c618b1bc3ff9a4db3c60921a5fd9736d559c6332 Mon Sep 17 00:00:00 2001 From: Fernando Alfaro Campos Date: Tue, 9 Sep 2025 16:44:52 -0400 Subject: [PATCH 1/3] Update workflow action for csm docs version update --- .github/scripts/update_csm_docs_versions.sh | 266 ++++++++++++++++++++ .github/workflows/csm-versions-update.yaml | 157 ++---------- 2 files changed, 285 insertions(+), 138 deletions(-) create mode 100644 .github/scripts/update_csm_docs_versions.sh diff --git a/.github/scripts/update_csm_docs_versions.sh b/.github/scripts/update_csm_docs_versions.sh new file mode 100644 index 00000000..f2b1e1c4 --- /dev/null +++ b/.github/scripts/update_csm_docs_versions.sh @@ -0,0 +1,266 @@ +#! /bin/bash + +declare -A all_images +declare -A csm_module_images + +# CSM Drivers +declare -A csi_driver_images +csi_driver_images[csi-powerscale]="" +csi_driver_images[csi-powerstore]="" +csi_driver_images[csi-powermax]="" +csi_driver_images[csi-vxflexos]="" +csi_driver_images[csi-unity]="" + +# CSI Sidecars +declare -A csi_sidecar_images +csi_sidecar_images[attacher]="" +csi_sidecar_images[provisioner]="" +csi_sidecar_images[snapshotter]="" +csi_sidecar_images[resizer]="" +csi_sidecar_images[registrar]="" +csi_sidecar_images[external-health-monitor]="" + +version_content_file="versions-content.txt" + +get_all_images_raw() { + readarray -t lines < $version_content_file + for line in "${lines[@]}"; do + if [[ -z $line ]] || [[ $line =~ ^# ]]; then + continue + fi + + name=$(echo $line | cut -d: -f1 | tr -d ' ') + version=$(echo $line | cut -d: -f2 | tr -d ' ') + + if [[ $name == "csm-replication" ]]; then + all_images[replicator]=$version + continue + elif [[ $name == "karavi-resiliency" ]]; then + all_images[podmon]=$version + continue + elif [[ $name == "csm-authorization-v2" ]]; then + all_images[authorization]=$version + continue + elif [[ $name == "csireverseproxy" ]]; then + all_images[reverseproxy]=$version + continue + elif [[ $name == "csi-powerscale" ]]; then + all_images[isilon]=$version + continue + fi + + all_images[$name]=$version + done +} + +# Creates appropriate map for just the CSI Sidecars images. +# This is to be used for easier substitution. +update_modules_versions() { + # Parse out and save each needed CSM version + readarray -t lines < $version_content_file + for line in "${lines[@]}"; do + name=$(echo $line | cut -d: -f1 | tr -d ' ') + version=$(echo $line | cut -d: -f2 | tr -d ' ') + + if [[ $name == "csm-replication" ]]; then + csm_module_images[replication]=$version + elif [[ $name == "karavi-resiliency" ]]; then + csm_module_images[resiliency]=$version + elif [[ $name == "csm-authorization-v2" ]]; then + csm_module_images[authorization]=$version + elif [[ $name == "csireverseproxy" ]]; then + csm_module_images[csireverseproxy]=$version + elif [[ $name == "karavi-observability" ]]; then + csm_module_images[observability]=$version + elif [ "$name" == "csm-metrics-powerstore" ] || [ "$name" == "csm-metrics-powerscale" ] || [ "$name" == "csm-metrics-powermax" ]; then + csm_module_images[$name]=$version + fi + done +} + +# Creates appropriate map for just the CSI Sidecars images. +update_csi_sidecars_versions() { + for key in "${!csi_sidecar_images[@]}"; do + version=$(cat $version_content_file | grep "$key" | cut -d: -f2 | tr -d ' ') + csi_sidecar_images[$key]=$version + done +} + +# Creates appropriate map for just the CSI Driver images. +update_csi_drivers_versions() { + for key in "${!csi_driver_images[@]}"; do + version=$(cat $version_content_file | grep "$key" | cut -d: -f2 | tr -d ' ') + csi_driver_images[$key]=$version + done +} + +# Updates the version in the shortcodes. This needs to be aligned properly +# with the naming conventions. +update_shortcodes() { + for key in "${!all_images[@]}"; do + path="layouts/shortcodes/version-docs.html" + name=$(echo $key | tr '-' '_') + version=${all_images[$key]} + + # If no shortcode was found, we don't need to update it + if ! grep -q "\"$name.*\" -}}" $path; then + echo "No shortcode found for $key. Skipping." + continue + fi + + old_shortcode=$(grep -r "\"$name.*\" -}}" $path) + + # If shortcode already contains the version, we don't need to update it + if [[ "$old_shortcode" == *"$version"* ]]; then + continue + fi + + new_shortcode=$(echo $old_shortcode | sed "s/}}.*/}}$version/") + + updated_shortcodes+="\t$key to $version\n" + sed -i "s|${old_shortcode}|${new_shortcode}|g" $path + done +} + +# Specific substitution needed due to the fact that the overall helm file is formatting in a different manner. +update_installation_wizard_helm() { + echo "Starting installation wizard helm update..." + # Sanitize the CSM version + csm_version=$(echo ${all_images[csm-version]} | tr -d 'v' | tr -d '\r') + + # The installation wizard templates should have the latest version of the CSM. + wizard_files=$(find content/docs/getting-started/installation/installationwizard/src/templates/helm/ -name "*$csm_version*") + + if [ -z "$wizard_files" ]; then + echo "No Installation Wizard content for latest CSM found. Skipping." + return + fi + + for file in $wizard_files; do + updated_images="" + for key in "${!all_images[@]}"; do + # Retrieve the current version from the file of the sidecar. + old_version=$(grep -m 1 -E ".*image.*$key.*" $file | xargs) + if [ -z "$old_version" ]; then + continue + fi + + # All instance of the image in a file either go "image:/value:" so we remove that to get the pure image. + old_version=$(echo $old_version | cut -d':' -f2- | tr -d ' ') + new_version=$(echo $old_version | sed "s/:.*/:${all_images[$key]}/") + + # If the version is the same, then we skip + if [ "$old_version" == "$new_version" ]; then + continue + fi + + updated_images+="\t$new_version\n" + + # Update the version in the file. + sed -i "s|${old_version}|${new_version}|g" $file + done + + if [ -z "$updated_images" ]; then + continue + fi + + updated_installation_wizard+="Updated $file with the following images:\n$updated_images\n" + done +} + +# Properly parses the contents of each operator file and updates the image versions. +update_installation_wizard_operator() { + echo "Starting installation wizard operator update..." + + # Sanitize the CSM version + csm_version=$(echo ${all_images[csm-version]} | tr -d 'v' | tr -d '\r') + + wizard_files=$(find content/docs/getting-started/installation/installationwizard/src/templates/operator/ -name "*$csm_version*") + + if [ -z "$wizard_files" ]; then + echo "No Installation Wizard content for latest CSM found. Skipping." + return + fi + + for file in $wizard_files; do + driver_name="" + if grep -q "isilon" $file; then + driver_name="csi-powerscale" + elif grep -q "powerstore" $file; then + driver_name="csi-powerstore" + elif grep -q "powermax" $file; then + driver_name="csi-powermax" + fi + + latest_version=${csi_driver_images[$driver_name]} + + # Update Driver version + yq -i e "(.spec.driver.configVersion) = \"$latest_version\"" $file + + # Update Driver image + yq -i e "(.spec.driver.common.image) |= sub(\":.*\"; \":$latest_version\")" $file + + # Update the modules. + for key in "${!csm_module_images[@]}"; do + # Retrieve latest version + image_name=$key + latest_version=${csm_module_images[$image_name]} + + # Update configVersion + yq -i e "(.spec.modules[] | select(.name == \"$key\") | .configVersion) = \"$latest_version\"" $file + + # Since the image of observability is different for each driver, substitution is specific. + if [[ $key == "observability" ]]; then + component_name="" + + if grep -q "powerstore" $file; then + component_name="metrics-powerstore" + elif grep -q "powermax" $file; then + component_name="metrics-powermax" + elif grep -q "isilon" $file; then + component_name="metrics-powerscale" + fi + + if [ $component_name == "" ]; then + echo "File is not a valid format in name" + continue + fi + + latest_version=${csm_module_images["csm-"$component_name]} + + yq -i e "(.spec.modules[] | select(.name == \"$key\") | .components[] | select(.name == \"$component_name\") | .image) |= sub(\":.*\"; \":$latest_version\")" $file + + # Update otel-collector and nginx + otel_version=${all_images["otel-collector"]} + yq -i e "(.spec.modules[] | select(.name == \"$key\") | .components[] | select(.name == \"otel-collector\") | .image) |= sub(\":.*\"; \":$otel_version\")" $file + + # Update nginx-unprivileged + nginx_version=${all_images["nginx-unprivileged"]} + yq -i e "(.spec.modules[] | select(.name == \"$key\") | .components[] | select(.name == \"otel-collector\") | .envs[] | select(.name == \"NGINX_PROXY_IMAGE\") | .value) |= sub(\":.*\"; \":$nginx_version\")" $file + continue + fi + + # Update all the images if they are the only image in the sidecar. + yq -i e "(.spec.modules[] | select(.name == \"$key\") | .components[] | .image) |= sub(\":.*\"; \":$latest_version\")" $file + done + + # Update the csi sidecars + for key in "${!csi_sidecar_images[@]}"; do + # Retrieve latest version + image_name=$key + latest_version=${csi_sidecar_images[$image_name]} + + # Update all the images if they are the only image in the sidecar. + yq -i e "(.spec.driver.sideCars[] | select(.name == \"$image_name\") | .image) |= sub(\":.*\"; \":$latest_version\")" $file + done + done +} + + +get_all_images_raw +update_modules_versions +update_csi_sidecars_versions +update_csi_drivers_versions +update_shortcodes +update_installation_wizard_helm +update_installation_wizard_operator diff --git a/.github/workflows/csm-versions-update.yaml b/.github/workflows/csm-versions-update.yaml index 901ad9da..ba03d3f7 100644 --- a/.github/workflows/csm-versions-update.yaml +++ b/.github/workflows/csm-versions-update.yaml @@ -25,153 +25,33 @@ jobs: run: | curl -s https://raw.githubusercontent.com/dell/csm/refs/heads/main/config/csm-versions.yaml > versions-content.txt - # Parse out and save each needed CSM version - readarray -t lines < versions-content.txt - for line in "${lines[@]}"; do - name=$(echo $line | cut -d: -f1 | tr -d ' ') - version=$(echo $line | cut -d: -f2 | tr -d ' ') - - if [[ $name == "csi-attacher" ]]; then - echo "attacher=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "csi-provisioner" ]]; then - echo "provisioner=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "csi-snapshotter" ]]; then - echo "snapshotter=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "csi-resizer" ]]; then - echo "resizer=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "csi-node-driver-registrar" ]]; then - echo "registrar=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "csi-external-health-monitor-controller" ]]; then - echo "health_monitor=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "csm-version" ]]; then - echo "csm=$version" >> "$GITHUB_OUTPUT" - elif [[ $name == "otel-collector" ]]; then - echo "otel_collector=$version" >> "$GITHUB_OUTPUT" - fi - - done - - name: CSM docs versions update if: ${{ github.repository == 'dell/csm-docs' }} - env: - attacher: ${{ steps.vars.outputs.attacher }} - provisioner: ${{ steps.vars.outputs.provisioner }} - snapshotter: ${{ steps.vars.outputs.snapshotter }} - resizer: ${{ steps.vars.outputs.resizer }} - registrar: ${{ steps.vars.outputs.registrar }} - health_monitor: ${{ steps.vars.outputs.health_monitor }} - otel_collector: ${{ steps.vars.outputs.otel_collector }} - csm: ${{ steps.vars.outputs.csm }} run: | - declare -A latest_images - latest_images[csi-attacher]=$attacher - latest_images[csi-provisioner]=$provisioner - latest_images[csi-snapshotter]=$snapshotter - latest_images[csi-resizer]=$resizer - latest_images[csi-node-driver-registrar]=$registrar - latest_images[csi-external-health-monitor-controller]=$health_monitor - latest_images[opentelemetry-collector]=$otel_collector - - # Global variables - updated_shortcodes="" - updated_installation_wizard="" - - update_shortcodes() { - for key in "${!latest_images[@]}"; do - path="layouts/shortcodes/version-docs.html" - name=$(echo $key | tr '-' '_') - version=${latest_images[$key]} - - # If no shortcode was found, we don't need to update it - if ! grep -q "\"$name.*\" -}}" $path; then - echo "No shortcode found for $key. Skipping." - continue - fi - - old_shortcode=$(grep -r "\"$name.*\" -}}" $path) - - # If shortcode already contains the version, we don't need to update it - if [[ "$old_shortcode" == *"$version"* ]]; then - continue - fi - - new_shortcode=$(echo $old_shortcode | sed "s/}}.*/}}$version/") - - updated_shortcodes+="\t$key to $version\n" - sed -i "s|${old_shortcode}|${new_shortcode}|g" $path - done - } - - update_installation_wizard() { - echo "Starting installation wizard update..." - # Sanitize the CSM version - csm_version=$(echo $csm | tr -d 'v' | tr -d '\r') - - # The installation wizard templates should have the latest version of the CSM. - wizard_files=$(find content/docs/getting-started/installation/installationwizard/src/templates/ -name "*$csm_version*") - - if [ -z "$wizard_files" ]; then - echo "No Installation Wizard content for latest CSM found. Skipping." - return - fi + curl -sfL https://raw.githubusercontent.com/dell/common-github-actions/main/.github/scripts/update_csm_docs_versions.sh -o update_csm_docs_versions.sh + chmod +x update_csm_docs_versions.sh + bash update_csm_docs_versions.sh - for file in $wizard_files; do - updated_images="" - for key in "${!latest_images[@]}"; do - # Retrieve the current version from the file of the sidecar. - old_version=$(grep -r -m 1 "$key:" $file | xargs) - if [ -z "$old_version" ]; then - continue - fi - - # All instance of the image in a file either go "image:/value:" so we remove that to get the pure image. - old_version=$(echo $old_version | cut -d':' -f2- | tr -d ' ') - new_version=$(echo $old_version | sed "s/:.*/:${latest_images[$key]}/") - - # If the version is the same, then we skip - if [ "$old_version" == "$new_version" ]; then - continue - fi - - updated_images+="\t$new_version\n" - - # Update the version in the file. - sed -i "s|${old_version}|${new_version}|g" $file - done - - if [ -z "$updated_images" ]; then - continue - fi - - updated_installation_wizard+="Updated $file with the following images:\n$updated_images\n" - done - } - - handle_results() { - if [ -z "$updated_shortcodes" ] && [ -z "$updated_installation_wizard" ]; then - echo "No changes were made. Skipping." - return - fi - - if [ -n "$updated_shortcodes" ]; then - echo -e "Updated Shortcodes:\n$updated_shortcodes" - fi - - if [ -n "$updated_installation_wizard" ]; then - echo -e "$updated_installation_wizard" - fi - } - - update_shortcodes - update_installation_wizard - handle_results + - name: Remove Remaining Files + run: | + rm versions-content.txt + rm update_csm_docs_versions.sh - - name: Remove versions content file - run: rm versions-content.txt + - name: Determine Changes + id: determine_changes + run: | + if git diff --quiet; then + echo "Everything is up to date. No changes detected." + echo "makePullRequest=false" >> "$GITHUB_OUTPUT" + else + echo "Changes detected, pull request will be created." + echo "makePullRequest=true" >> "$GITHUB_OUTPUT" + fi # Needed for signing commits using Github App tokens # See: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#commit-signing - name: Generate GitHub App Token + if: ${{ steps.determine_changes.outputs.makePullRequest == 'true' }} uses: actions/create-github-app-token@v2.1.1 id: generate-token with: @@ -181,6 +61,7 @@ jobs: # Must enable "allow GitHub Actions to create pull requests" setting # Author defaults to the user who triggered the workflow run - name: Create pull request + if: ${{ steps.determine_changes.outputs.makePullRequest == 'true' }} uses: peter-evans/create-pull-request@v7 with: token: ${{ steps.generate-token.outputs.token }} From 47f320a24b3d7ac16cea28cac165aa0532c98fa8 Mon Sep 17 00:00:00 2001 From: Fernando Alfaro Campos Date: Tue, 9 Sep 2025 19:13:53 -0400 Subject: [PATCH 2/3] Add copyrights --- .github/scripts/update_csm_docs_versions.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/scripts/update_csm_docs_versions.sh b/.github/scripts/update_csm_docs_versions.sh index f2b1e1c4..c2d92dd5 100644 --- a/.github/scripts/update_csm_docs_versions.sh +++ b/.github/scripts/update_csm_docs_versions.sh @@ -1,3 +1,11 @@ +# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 + #! /bin/bash declare -A all_images From 96877800746f54cf91a7ff925e7fc78fca0d2456 Mon Sep 17 00:00:00 2001 From: Fernando Alfaro Campos Date: Wed, 10 Sep 2025 10:32:07 -0400 Subject: [PATCH 3/3] Address PR comments --- .github/scripts/update_csm_docs_versions.sh | 45 +++++++++------------ .github/workflows/csm-versions-update.yaml | 13 ------ 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/.github/scripts/update_csm_docs_versions.sh b/.github/scripts/update_csm_docs_versions.sh index c2d92dd5..b80aa5e9 100644 --- a/.github/scripts/update_csm_docs_versions.sh +++ b/.github/scripts/update_csm_docs_versions.sh @@ -105,6 +105,7 @@ update_csi_drivers_versions() { # Updates the version in the shortcodes. This needs to be aligned properly # with the naming conventions. update_shortcodes() { + echo "Checking to see if any shortcodes need to be updated..." for key in "${!all_images[@]}"; do path="layouts/shortcodes/version-docs.html" name=$(echo $key | tr '-' '_') @@ -125,14 +126,13 @@ update_shortcodes() { new_shortcode=$(echo $old_shortcode | sed "s/}}.*/}}$version/") - updated_shortcodes+="\t$key to $version\n" sed -i "s|${old_shortcode}|${new_shortcode}|g" $path done } # Specific substitution needed due to the fact that the overall helm file is formatting in a different manner. update_installation_wizard_helm() { - echo "Starting installation wizard helm update..." + echo "Checking to see if any installation wizard helm files need to be updated..." # Sanitize the CSM version csm_version=$(echo ${all_images[csm-version]} | tr -d 'v' | tr -d '\r') @@ -145,40 +145,32 @@ update_installation_wizard_helm() { fi for file in $wizard_files; do - updated_images="" for key in "${!all_images[@]}"; do - # Retrieve the current version from the file of the sidecar. - old_version=$(grep -m 1 -E ".*image.*$key.*" $file | xargs) - if [ -z "$old_version" ]; then - continue - fi - - # All instance of the image in a file either go "image:/value:" so we remove that to get the pure image. - old_version=$(echo $old_version | cut -d':' -f2- | tr -d ' ') - new_version=$(echo $old_version | sed "s/:.*/:${all_images[$key]}/") + # Retrieve the current version from the file of the sidecar. + old_version=$(grep -m 1 -E ".*image.*$key.*" $file | xargs) + if [ -z "$old_version" ]; then + continue + fi - # If the version is the same, then we skip - if [ "$old_version" == "$new_version" ]; then - continue - fi + # All instance of the image in a file either go "image:/value:" so we remove that to get the pure image. + old_version=$(echo $old_version | cut -d':' -f2- | tr -d ' ') + new_version=$(echo $old_version | sed "s/:.*/:${all_images[$key]}/") - updated_images+="\t$new_version\n" + # If the version is the same, then we skip + if [ "$old_version" == "$new_version" ]; then + continue + fi - # Update the version in the file. - sed -i "s|${old_version}|${new_version}|g" $file + # Update the version in the file. + sed -i "s|${old_version}|${new_version}|g" $file done - - if [ -z "$updated_images" ]; then - continue - fi - - updated_installation_wizard+="Updated $file with the following images:\n$updated_images\n" done } # Properly parses the contents of each operator file and updates the image versions. +# Due to the use of 'yq', exact changes will not be tracked until the pull request is created. update_installation_wizard_operator() { - echo "Starting installation wizard operator update..." + echo "Checking to see if any installation wizard operator files need to be updated..." # Sanitize the CSM version csm_version=$(echo ${all_images[csm-version]} | tr -d 'v' | tr -d '\r') @@ -269,6 +261,7 @@ get_all_images_raw update_modules_versions update_csi_sidecars_versions update_csi_drivers_versions + update_shortcodes update_installation_wizard_helm update_installation_wizard_operator diff --git a/.github/workflows/csm-versions-update.yaml b/.github/workflows/csm-versions-update.yaml index ba03d3f7..6f329de9 100644 --- a/.github/workflows/csm-versions-update.yaml +++ b/.github/workflows/csm-versions-update.yaml @@ -37,21 +37,9 @@ jobs: rm versions-content.txt rm update_csm_docs_versions.sh - - name: Determine Changes - id: determine_changes - run: | - if git diff --quiet; then - echo "Everything is up to date. No changes detected." - echo "makePullRequest=false" >> "$GITHUB_OUTPUT" - else - echo "Changes detected, pull request will be created." - echo "makePullRequest=true" >> "$GITHUB_OUTPUT" - fi - # Needed for signing commits using Github App tokens # See: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#commit-signing - name: Generate GitHub App Token - if: ${{ steps.determine_changes.outputs.makePullRequest == 'true' }} uses: actions/create-github-app-token@v2.1.1 id: generate-token with: @@ -61,7 +49,6 @@ jobs: # Must enable "allow GitHub Actions to create pull requests" setting # Author defaults to the user who triggered the workflow run - name: Create pull request - if: ${{ steps.determine_changes.outputs.makePullRequest == 'true' }} uses: peter-evans/create-pull-request@v7 with: token: ${{ steps.generate-token.outputs.token }}