|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +exit_code=0 |
| 4 | + |
| 5 | +echo "Fast-forward workflow inputs: |
| 6 | +* REPO_MAP_PATH: ${REPO_MAP_PATH} |
| 7 | +* DESTINATION_VERSIONS: ${DESTINATION_VERSIONS} |
| 8 | +" |
| 9 | + |
| 10 | +if [[ ! -f "${REPO_MAP_PATH}" ]]; then |
| 11 | + echo "ERROR: REPO_MAP_PATH '${REPO_MAP_PATH}' not found" |
| 12 | + exit 1 |
| 13 | +fi |
| 14 | + |
| 15 | +if [[ -z "${DESTINATION_VERSIONS}" ]]; then |
| 16 | + echo "ERROR: DESTINATION_VERSIONS may not be empty" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +for version in ${DESTINATION_VERSIONS}; do |
| 21 | + if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+$ ]]; then |
| 22 | + echo "ERROR: Version '$version' is not in X.Y format" |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | +done |
| 26 | + |
| 27 | +for product in mce acm; do |
| 28 | + component_repos=$(yq '.components[] | |
| 29 | + select(.bundle == "'"${product}-operator-bundle"'" and |
| 30 | + .repository == "https://github.com/stolostron/*").repository' "${REPO_MAP_PATH}") |
| 31 | + for repo in ${component_repos}; do |
| 32 | + owner_repo=${repo#https://github.com/} |
| 33 | + # owner=${owner_repo%/*} |
| 34 | + repo=${owner_repo#*/} |
| 35 | + |
| 36 | + echo "INFO: Handling ${owner_repo}" |
| 37 | + |
| 38 | + branch_prefix="release" |
| 39 | + if [[ ${product} == "mce" ]]; then |
| 40 | + branch_prefix="backplane" |
| 41 | + fi |
| 42 | + |
| 43 | + for version in ${DESTINATION_VERSIONS}; do |
| 44 | + branch="${branch_prefix}-${version}" |
| 45 | + echo "INFO: Fast-forwarding ${owner_repo} main to branch: ${branch}" |
| 46 | + # log_file="${ARTIFACT_DIR}/fastforward-${owner_repo}-${branch}.log" |
| 47 | + # REPO_OWNER=${owner} \ |
| 48 | + # REPO_NAME=${repo} \ |
| 49 | + # SOURCE_BRANCH=main \ |
| 50 | + # DESTINATION_BRANCH=${branch} \ |
| 51 | + # ../fastforward/ocm-ci-fastforward-commands.sh >"${log_file}" 2>&1 || |
| 52 | + # { |
| 53 | + # exit_code=$? |
| 54 | + # echo "ERROR: Failed to fast-forward ${owner_repo} to branch: ${branch}" |
| 55 | + # echo "Logs:" |
| 56 | + # sed 's/^/ /' "${log_file}" |
| 57 | + # } |
| 58 | + done |
| 59 | + done |
| 60 | +done |
| 61 | + |
| 62 | +exit ${exit_code} |
0 commit comments