Skip to content

Commit

Permalink
Add OLM channels recovery script. (#955)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Andriienko <[email protected]>
  • Loading branch information
AndrienkoAleksandr authored Jul 21, 2021
1 parent 5ab4154 commit ca6f98c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/bin/recovery-olm-channels.sh
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .github/workflows/recovery-index-images.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ca6f98c

Please sign in to comment.