From 31b099d6709384f18810d436e398a7c340f03d2f Mon Sep 17 00:00:00 2001 From: Stan Lewis Date: Wed, 26 Aug 2026 08:48:05 -0400 Subject: [PATCH 1/2] fix(export-dynamic): verify registry artifacts before skipping workspace (RHDHBUGS-3635) Assisted-By: opencode Signed-off-by: Stan Lewis rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- export-dynamic/export-dynamic.sh | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/export-dynamic/export-dynamic.sh b/export-dynamic/export-dynamic.sh index 5c1d886..184425f 100755 --- a/export-dynamic/export-dynamic.sh +++ b/export-dynamic/export-dynamic.sh @@ -85,6 +85,44 @@ then popd > /dev/null fi +if [[ "${skipWorkspace}" == "true" ]] +then + # If we are publishing containers, verify that all expected artifacts exist in the registry and are valid before skipping + if [[ "${INPUTS_IMAGE_REPOSITORY_PREFIX}" != "" && "${INPUTS_PUSH_CONTAINER_IMAGE}" == "true" && -f "${INPUTS_PLUGINS_FILE}" ]] + then + if command -v skopeo >/dev/null 2>&1 + then + echo "Verifying published artifacts in registry for workspace before skipping..." + while IFS= read -r plugin || [[ -n "$plugin" ]] + do + # Skip empty lines + if [[ -z "${plugin// /}" ]]; then + continue + fi + # Skip commented lines + # shellcheck disable=SC2001 + if [[ "$(echo "$plugin" | sed 's/^#.*//')" == "" ]]; then + continue + fi + # shellcheck disable=SC2001 + pluginPath=$(echo "$plugin" | sed 's/^\(^[^:]*\): *\(.*\)$/\1/') + if [ -d "$pluginPath" ] && [ -f "$pluginPath/package.json" ]; then + PLUGIN_NAME=$(jq -r '.name | sub("^@"; "") | sub("[/@]"; "-")' "$pluginPath/package.json") + PLUGIN_VERSION="${INPUTS_IMAGE_TAG_PREFIX}$(jq -r '.version' "$pluginPath/package.json")" + PLUGIN_CONTAINER_TAG="${INPUTS_IMAGE_REPOSITORY_PREFIX}/${PLUGIN_NAME}:${PLUGIN_VERSION}" + echo " Checking registry for ${PLUGIN_CONTAINER_TAG}..." + if ! skopeo inspect --raw "docker://${PLUGIN_CONTAINER_TAG}" 2>/dev/null | jq -e '.annotations["io.backstage.dynamic-packages"] | @base64d | fromjson | length > 0' >/dev/null 2>&1; then + echo " Missing or invalid artifact in registry: ${PLUGIN_CONTAINER_TAG}. Workspace cannot be skipped." + skipWorkspace=false + break + fi + echo " Verified valid artifact in registry: ${PLUGIN_CONTAINER_TAG}" + fi + done < "${INPUTS_PLUGINS_FILE}" + fi + fi +fi + if [[ "${skipWorkspace}" == "true" ]] then echo "Skipping workspace since it didn't change since last published commit (${INPUTS_LAST_PUBLISH_COMMIT})" From 9a465a193b9970a529d1d1d9275c0be2db160307 Mon Sep 17 00:00:00 2001 From: Stan Lewis Date: Wed, 26 Aug 2026 08:52:33 -0400 Subject: [PATCH 2/2] fix: flatten conditional and use double brackets for conditional test Assisted-By: opencode Signed-off-by: Stan Lewis rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED --- export-dynamic/export-dynamic.sh | 61 ++++++++++++++------------------ 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/export-dynamic/export-dynamic.sh b/export-dynamic/export-dynamic.sh index 184425f..ce05b54 100755 --- a/export-dynamic/export-dynamic.sh +++ b/export-dynamic/export-dynamic.sh @@ -85,42 +85,35 @@ then popd > /dev/null fi -if [[ "${skipWorkspace}" == "true" ]] +if [[ "${skipWorkspace}" == "true" && "${INPUTS_IMAGE_REPOSITORY_PREFIX}" != "" && "${INPUTS_PUSH_CONTAINER_IMAGE}" == "true" && -f "${INPUTS_PLUGINS_FILE}" ]] && command -v skopeo >/dev/null 2>&1 then - # If we are publishing containers, verify that all expected artifacts exist in the registry and are valid before skipping - if [[ "${INPUTS_IMAGE_REPOSITORY_PREFIX}" != "" && "${INPUTS_PUSH_CONTAINER_IMAGE}" == "true" && -f "${INPUTS_PLUGINS_FILE}" ]] - then - if command -v skopeo >/dev/null 2>&1 - then - echo "Verifying published artifacts in registry for workspace before skipping..." - while IFS= read -r plugin || [[ -n "$plugin" ]] - do - # Skip empty lines - if [[ -z "${plugin// /}" ]]; then - continue - fi - # Skip commented lines - # shellcheck disable=SC2001 - if [[ "$(echo "$plugin" | sed 's/^#.*//')" == "" ]]; then - continue - fi - # shellcheck disable=SC2001 - pluginPath=$(echo "$plugin" | sed 's/^\(^[^:]*\): *\(.*\)$/\1/') - if [ -d "$pluginPath" ] && [ -f "$pluginPath/package.json" ]; then - PLUGIN_NAME=$(jq -r '.name | sub("^@"; "") | sub("[/@]"; "-")' "$pluginPath/package.json") - PLUGIN_VERSION="${INPUTS_IMAGE_TAG_PREFIX}$(jq -r '.version' "$pluginPath/package.json")" - PLUGIN_CONTAINER_TAG="${INPUTS_IMAGE_REPOSITORY_PREFIX}/${PLUGIN_NAME}:${PLUGIN_VERSION}" - echo " Checking registry for ${PLUGIN_CONTAINER_TAG}..." - if ! skopeo inspect --raw "docker://${PLUGIN_CONTAINER_TAG}" 2>/dev/null | jq -e '.annotations["io.backstage.dynamic-packages"] | @base64d | fromjson | length > 0' >/dev/null 2>&1; then - echo " Missing or invalid artifact in registry: ${PLUGIN_CONTAINER_TAG}. Workspace cannot be skipped." - skipWorkspace=false - break - fi - echo " Verified valid artifact in registry: ${PLUGIN_CONTAINER_TAG}" - fi - done < "${INPUTS_PLUGINS_FILE}" + echo "Verifying published artifacts in registry for workspace before skipping..." + while IFS= read -r plugin || [[ -n "$plugin" ]] + do + # Skip empty lines + if [[ -z "${plugin// /}" ]]; then + continue fi - fi + # Skip commented lines + # shellcheck disable=SC2001 + if [[ "$(echo "$plugin" | sed 's/^#.*//')" == "" ]]; then + continue + fi + # shellcheck disable=SC2001 + pluginPath=$(echo "$plugin" | sed 's/^\(^[^:]*\): *\(.*\)$/\1/') + if [[ -d "$pluginPath" && -f "$pluginPath/package.json" ]]; then + PLUGIN_NAME=$(jq -r '.name | sub("^@"; "") | sub("[/@]"; "-")' "$pluginPath/package.json") + PLUGIN_VERSION="${INPUTS_IMAGE_TAG_PREFIX}$(jq -r '.version' "$pluginPath/package.json")" + PLUGIN_CONTAINER_TAG="${INPUTS_IMAGE_REPOSITORY_PREFIX}/${PLUGIN_NAME}:${PLUGIN_VERSION}" + echo " Checking registry for ${PLUGIN_CONTAINER_TAG}..." + if ! skopeo inspect --raw "docker://${PLUGIN_CONTAINER_TAG}" 2>/dev/null | jq -e '.annotations["io.backstage.dynamic-packages"] | @base64d | fromjson | length > 0' >/dev/null 2>&1; then + echo " Missing or invalid artifact in registry: ${PLUGIN_CONTAINER_TAG}. Workspace cannot be skipped." + skipWorkspace=false + break + fi + echo " Verified valid artifact in registry: ${PLUGIN_CONTAINER_TAG}" + fi + done < "${INPUTS_PLUGINS_FILE}" fi if [[ "${skipWorkspace}" == "true" ]]