Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions export-dynamic/export-dynamic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,37 @@ then
popd > /dev/null
fi

if [[ "${skipWorkspace}" == "true" && "${INPUTS_IMAGE_REPOSITORY_PREFIX}" != "" && "${INPUTS_PUSH_CONTAINER_IMAGE}" == "true" && -f "${INPUTS_PLUGINS_FILE}" ]] && 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

if [[ "${skipWorkspace}" == "true" ]]
then
echo "Skipping workspace since it didn't change since last published commit (${INPUTS_LAST_PUBLISH_COMMIT})"
Expand Down