From 8486cd38d8e7fdb946360b8c17af68614909e164 Mon Sep 17 00:00:00 2001 From: Eloy Coto Date: Wed, 4 Mar 2026 22:34:33 +0100 Subject: [PATCH] feat(x2a): push images to quay --- .../x2a/scripts/build-dynamic-plugins.sh | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/workspaces/x2a/scripts/build-dynamic-plugins.sh b/workspaces/x2a/scripts/build-dynamic-plugins.sh index 018865cfc4..5b219be727 100755 --- a/workspaces/x2a/scripts/build-dynamic-plugins.sh +++ b/workspaces/x2a/scripts/build-dynamic-plugins.sh @@ -2,9 +2,12 @@ # # Build x2a dynamic plugins and package them as OCI images. # -# Usage: ./scripts/build-dynamic-plugins.sh +# Usage: ./scripts/build-dynamic-plugins.sh [--push] # -# Produces two OCI images: +# Options: +# --push Push built images to the registry after packaging +# +# Produces OCI images: # quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-x2a: # quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-x2a-backend: # @@ -16,6 +19,7 @@ WORKSPACE_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" RHDH_CLI_VERSION="1.9.1" EMBED_PACKAGE="@red-hat-developer-hub/backstage-plugin-x2a-common" IMAGE_REGISTRY="quay.io/x2ansible" +PUSH_IMAGES=false declare -A PLUGIN_IMAGES=( ["x2a"]="red-hat-developer-hub-backstage-plugin-x2a" @@ -98,14 +102,34 @@ package_plugin() { log "Packaging plugin image: ${image_tag}" (cd "$plugin_path" && npx "@red-hat-developer-hub/cli@${RHDH_CLI_VERSION}" plugin package \ -t "$image_tag") +} +push_plugin() { + local plugin_dir="$1" + local image_name="${PLUGIN_IMAGES[$plugin_dir]}" + local version + version="$(get_plugin_version "$plugin_dir")" + local image_tag="${IMAGE_REGISTRY}/${image_name}:${version}" + + log "Pushing image: ${image_tag}" + podman push "$image_tag" } # --------------------------------------------------------------------------- # Main # --------------------------------------------------------------------------- +parse_args() { + for arg in "$@"; do + case "$arg" in + --push) PUSH_IMAGES=true ;; + *) echo "ERROR: unknown argument: $arg" >&2; exit 1 ;; + esac + done +} + main() { + parse_args "$@" check_prerequisites install_dependencies build_workspace @@ -117,6 +141,13 @@ main() { log "Done. Images built:" podman images --filter "reference=${IMAGE_REGISTRY}/*" + + if [[ "$PUSH_IMAGES" == true ]]; then + for plugin_dir in "${!PLUGIN_IMAGES[@]}"; do + push_plugin "$plugin_dir" + done + log "All images pushed." + fi } main "$@"