Process FBC Fragment #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Process FBC Fragment | |
run-name: Process FBC Fragment | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- catalog/catalog-patch.yaml | |
branches: | |
- 'rhoai-2.1[6-9]+' | |
permissions: | |
contents: write | |
env: | |
GITHUB_ORG: red-hat-data-services | |
GITHUB_RKA_ORG: rhoai-rhtap | |
jobs: | |
process-fbc: | |
if: ${{ github.ref_name != 'main' }} | |
runs-on: ubuntu-latest | |
container: | |
image: quay.io/rhoai/rhoai-task-toolset:latest | |
options: --privileged | |
steps: | |
- name: Get Current branch name | |
shell: bash | |
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
id: get_branch | |
- name: Git checkout RBC main | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
path: main | |
- name: Git checkout RBC release | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.get_branch.outputs.branch }} | |
path: ${{ steps.get_branch.outputs.branch }} | |
- name: Git checkout utils | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.GITHUB_RKA_ORG }}/RHOAI-Konflux-Automation | |
ref: main | |
path: utils | |
- name: Install dependencies | |
run: | | |
os="$(uname -s | tr '[:upper:]' '[:lower:]')" | |
arch="$(uname -m | sed 's/x86_64/amd64/')" | |
yq_version="v4.44.3" | |
yq_filename="yq-$yq_version" | |
echo "-> Downloading yq" >&2 | |
curl -sSfLo "$yq_filename" "https://github.com/mikefarah/yq/releases/download/$yq_version/yq_${os}_${arch}" | |
chmod +x $yq_filename | |
ln -s $yq_filename yq | |
cp $yq_filename /usr/local/bin/yq | |
opm_version="v1.47.0" | |
opm_filename="opm-$opm_version" | |
echo "-> Downloading opm" >&2 | |
curl -sSfLo "$opm_filename" "https://github.com/operator-framework/operator-registry/releases/download/$opm_version/$os-$arch-opm" | |
chmod +x "$opm_filename" | |
ln -fs "$opm_filename" opm | |
cp "$opm_filename" /usr/local/bin/opm | |
pip install -r utils/utils/fbc-processor/requirements.txt | |
# - name: Podman Login | |
# uses: redhat-actions/podman-login@v1 | |
# with: | |
# registry: quay.io | |
# username: ${{ secrets.RHOAI_QUAY_RO_USERNAME }} | |
# password: ${{ secrets.RHOAI_QUAY_RO_TOKEN }} | |
- name: Process FBC Fragment | |
env: | |
BRANCH: ${{ steps.get_branch.outputs.branch }} | |
OC_TOKEN: ${{ secrets.KONFLUX_INTERNAL_OC_TOKEN }} | |
CLUSTER: p02 | |
RHOAI_QUAY_RO_USERNAME: ${{ secrets.RHOAI_QUAY_RO_USERNAME }} | |
RHOAI_QUAY_RO_TOKEN: ${{ secrets.RHOAI_QUAY_RO_TOKEN }} | |
RHOAI_QUAY_API_TOKEN: ${{ secrets.RHOAI_QUAY_API_TOKEN }} | |
run: | | |
#Declare basic variables | |
BUILD_CONFIG_PATH=${BRANCH}/config/build-config.yaml | |
RHOAI_VERSION=v${BRANCH/rhoai-/} | |
COMPONENT_SUFFIX=${RHOAI_VERSION/./-} | |
#OPERATOR_BUNDLE_COMPONENT_NAME=odh-operator-bundle-${COMPONENT_SUFFIX} | |
OPERATOR_BUNDLE_COMPONENT_NAME=odh-operator-bundle | |
PATCH_YAML_PATH=${BRANCH}/catalog/catalog-patch.yaml | |
OC_TOKEN=$(echo $OC_TOKEN | awk '{$1=$1};1' | tr -d '\n') | |
OPERATOR_BUNDLE_IMAGE_NAME=RELATED_IMAGE_ODH_OPERATOR_BUNDLE_IMAGE | |
echo "OPERATOR_BUNDLE_IMAGE_NAME = $OPERATOR_BUNDLE_IMAGE_NAME" | |
#Generate the catalog for the latest bundle | |
#podman login quay.io -u ${RHOAI_QUAY_RO_USERNAME} -p ${RHOAI_QUAY_RO_TOKEN} | |
BASE64_AUTH=$(echo -n "${RHOAI_QUAY_RO_USERNAME}:${RHOAI_QUAY_RO_TOKEN}" | base64 -w 0) | |
mkdir ${HOME}/.docker | |
echo '{"auths":{"quay.io/rhoai/odh-operator-bundle":{"username":"'"${RHOAI_QUAY_RO_USERNAME}"'","password":"'"${RHOAI_QUAY_RO_TOKEN}"'","email":"","auth":"'"${BASE64_AUTH}"'"}}}' > ${HOME}/.docker/config.json | |
APPLICATION_NAME=rhoai-${COMPONENT_SUFFIX} | |
echo "APPLICATION_NAME = $APPLICATION_NAME" | |
#Invoke the FBC processor to extract the snapshot images | |
CATALOG_BUILD_ARGS_FILE_PATH=${BRANCH}/catalog/catalog_build_args.map | |
python3 utils/utils/fbc-processor/fbc-processor.py -op extract-snapshot-images -o utils/snapshot_images.json -v ${BRANCH} -f ${OPERATOR_BUNDLE_COMPONENT_NAME} -b ${BUILD_CONFIG_PATH} --catalog-build-args-file-path ${CATALOG_BUILD_ARGS_FILE_PATH} | |
LATEST_BUNDLE_IMAGE=$(jq --arg OPERATOR_BUNDLE_IMAGE_NAME "$OPERATOR_BUNDLE_IMAGE_NAME" -r '.[] | select(.name == $OPERATOR_BUNDLE_IMAGE_NAME) | .value' utils/snapshot_images.json) | |
echo "LATEST_BUNDLE_IMAGE = $LATEST_BUNDLE_IMAGE" | |
yq e -i '.stable.bundles[0].image = "$LATEST_BUNDLE_IMAGE"' utils/utils/fbc-processor/fbc-semver-template.yaml | |
LATEST_BUNDLE_IMAGE="$LATEST_BUNDLE_IMAGE" yq e -i '.stable.bundles[0].image = env(LATEST_BUNDLE_IMAGE)' utils/utils/fbc-processor/fbc-semver-template.yaml | |
CSV_META_MIN_OCP_VERSION=417 | |
while IFS= read -r value; | |
do | |
OPENSHIFT_VERSION=$value | |
NUMERIC_OCP_VERSION=${OPENSHIFT_VERSION/v4./4} | |
CSV_META_OPM_FLAG="" | |
echo "OPENSHIFT_VERSION=$OPENSHIFT_VERSION" | |
if [[ $NUMERIC_OCP_VERSION -ge $CSV_META_MIN_OCP_VERSION ]] | |
then | |
CSV_META_OPM_FLAG="--migrate-level=bundle-object-to-csv-metadata" | |
fi | |
#Declare FBC processing variables | |
CATALOG_YAML_PATH=main/catalog/${OPENSHIFT_VERSION}/rhods-operator/catalog.yaml | |
SINGLE_BUNDLE_DIR=utils/utils/${OPENSHIFT_VERSION} | |
mkdir -p ${SINGLE_BUNDLE_DIR} | |
SINGLE_BUNDLE_PATH=${SINGLE_BUNDLE_DIR}/single_bundle_catalog_semver.yaml | |
OUTPUT_CATALOG_PATH=${BRANCH}/catalog/${OPENSHIFT_VERSION}/rhods-operator/catalog.yaml | |
#Generate the single bundle catalog | |
DOCKER_CONFIG=${HOME}/.docker/ opm alpha render-template semver ${CSV_META_OPM_FLAG} -o yaml utils/utils/fbc-processor/fbc-semver-template.yaml > ${SINGLE_BUNDLE_PATH} | |
PUSH_PIPELINE_PATH=${BRANCH}/.tekton/rhoai-fbc-fragment-${COMPONENT_SUFFIX}-push.yaml | |
#Invoke FBC processor to patch the catalog | |
python3 utils/utils/fbc-processor/fbc-processor.py -op catalog-patch -b ${BUILD_CONFIG_PATH} -c ${CATALOG_YAML_PATH} -p ${PATCH_YAML_PATH} -s ${SINGLE_BUNDLE_PATH} -o ${OUTPUT_CATALOG_PATH} --push-pipeline-yaml-path ${PUSH_PIPELINE_PATH} --push-pipeline-operation enable | |
#cat ${OUTPUT_CATALOG_PATH} | |
done < <(yq eval '.config.supported-ocp-versions.build[].name' $BUILD_CONFIG_PATH) | |
- name: Commit and push the changes to release branch | |
uses: actions-js/push@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.get_branch.outputs.branch }} | |
message: "Updating the catalog.yaml with latest images and patches" | |
repository: ${{ env.GITHUB_ORG }}/RHOAI-Build-Config | |
directory: ${{ steps.get_branch.outputs.branch }} | |
author_name: Openshift-AI DevOps | |
author_email: [email protected] | |