From ca6f98c53d790e846b7a53efba1b22147a643962 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 21 Jul 2021 18:21:24 +0300 Subject: [PATCH] Add OLM channels recovery script. (#955) Signed-off-by: Oleksandr Andriienko --- .github/bin/recovery-olm-channels.sh | 43 ++++++++++++++++++++ .github/workflows/recovery-index-images.yaml | 39 ++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 .github/bin/recovery-olm-channels.sh create mode 100644 .github/workflows/recovery-index-images.yaml diff --git a/.github/bin/recovery-olm-channels.sh b/.github/bin/recovery-olm-channels.sh new file mode 100755 index 000000000..dbed474cd --- /dev/null +++ b/.github/bin/recovery-olm-channels.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +if [ -n "${GITHUB_WORKSPACE}" ]; then + ROOT_PROJECT_DIR="${GITHUB_WORKSPACE}" +else + SCRIPT=$(readlink -f "${BASH_SOURCE[0]}") + ROOT_PROJECT_DIR=$(dirname $(dirname "$(dirname "$SCRIPT")")) +fi + +if [ -z "${IMAGE_REGISTRY_HOST}" ] || [ -z "${IMAGE_REGISTRY_USER_NAME}" ]; then + echo "[ERROR] Specify env variables with information about image registry 'IMAGE_REGISTRY_HOST' and 'IMAGE_REGISTRY_USER_NAME'." + exit 1 +fi + +source "${BASE_DIR}/olm.sh" +installOPM +${OPM_BINARY} version + +for platform in 'openshift' 'kubernetes'; do + echo "Recovery OLM channels for ${platform}" + + CATALOG_BUNDLE_IMAGE="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-bundles" + echo "[INFO] Bundle image without tag: ${CATALOG_BUNDLE_IMAGE}" + + declare -a BUNDLE_TAGS=($(skopeo list-tags docker://${CATALOG_BUNDLE_IMAGE} 2>/dev/null | jq -r ".Tags[] | @sh")) + BUNDLE_IMAGES="" + for tag in "${BUNDLE_TAGS[@]}"; do + tag=$(echo "${tag}" | tr -d "'") + BUNDLE_IMAGES="${BUNDLE_IMAGES},${CATALOG_BUNDLE_IMAGE}:${tag}" + done + # Remove first coma + BUNDLE_IMAGES="${BUNDLE_IMAGES#,}" + + echo "[INFO] List bundle images: ${BUNDLE_IMAGES}" + # Rebuild and push index image with all found bundles. + INDEX_IMG="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/eclipse-che-${platform}-opm-catalog:preview" + echo "[INFO] Rebuild and push catalog source image: " + echo "[INFO] ====================================== " + pushd "${ROOT_PROJECT_DIR}" || true + make catalog-build BUNDLE_IMGS="${BUNDLE_IMAGES}" CATALOG_IMG="${INDEX_IMG}" + make catalog-push CATALOG_IMG="${INDEX_IMG}" + popd || true +done diff --git a/.github/workflows/recovery-index-images.yaml b/.github/workflows/recovery-index-images.yaml new file mode 100644 index 000000000..1f6b30def --- /dev/null +++ b/.github/workflows/recovery-index-images.yaml @@ -0,0 +1,39 @@ +# +# Copyright (c) 2012-2021 Red Hat, Inc. +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +# +name: Recovery OLM channels in the index images +on: + # manual trigger if required + workflow_dispatch: + inputs: + reason: + description: 'Reason to trigger index images recovery' + required: false +jobs: + build-images: + name: Build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - name: Install yq + run: sudo pip install yq + - name: Docker login + uses: azure/docker-login@v1 + with: + login-server: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + - name: Build and push images to quay.io + run: > + ${GITHUB_WORKSPACE}/.github/bin/recovery-olm-channels.sh + env: + IMAGE_REGISTRY_HOST: quay.io + IMAGE_REGISTRY_USER_NAME: eclipse