Test & Publish OLM Package #95
Workflow file for this run
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
# action to test our operator lifecycle manager bundle | |
# See https://github.com/rabbitmq/OLM-Package-Repo for more info. | |
name: Test & Publish OLM Package | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
# registry information where we want to store the operator image and the operator index image | |
DOCKER_REGISTRY_SERVER: quay.io/rabbitmqoperator | |
OLM_IMAGE: rabbitmq-for-kubernetes-olm-cluster-operator | |
OLM_INDEX_IMAGE: rabbitmq-for-kubernetes-olm-cluster-operator-index | |
jobs: | |
create-olm-package: | |
name: Create the OLM Packaging | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'write' | |
id-token: 'write' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Checkout OLM-Package-Repo | |
uses: actions/checkout@v4 | |
with: | |
repository: rabbitmq/OLM-Package-Repo | |
path: ./OLM-Package-Repo | |
- name: Set image tag to tagged release | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
BUNDLE_VERSION=${GITHUB_REF#refs/*/} | |
echo "BUNDLE_VERSION=${BUNDLE_VERSION:1}" >> $GITHUB_ENV | |
shell: bash | |
- name: Set image tag to DEV version | |
if: startsWith(github.ref, 'refs/tags/v') == false | |
run: | | |
echo "BUNDLE_VERSION=0.0.0" >> $GITHUB_ENV | |
- name: Install and configure Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
- name: OpenShift Tools Installer | |
uses: redhat-actions/openshift-tools-installer@v1 | |
with: | |
# Using GitHub source because the Openshift mirror source binary file does not match the expected name | |
# pattern. In the mirror, the filename is opm-rhel8, and the Action is expecting the name as opm-${OS}-${ARCH} | |
source: github | |
github_pat: ${{ github.token }} | |
opm: "latest" | |
- name: carvel-setup-action | |
uses: carvel-dev/[email protected] | |
with: | |
token: ${{ github.token }} | |
only: ytt, kbld | |
- name: Podman Login | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY_SERVER }} | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_ROBOT_TOKEN }} | |
# TODO: Set auto-expiry in DEV images: https://idbs-engineering.com/containers/2019/08/27/auto-expiry-quayio-tags.html | |
- name: Create OLM Package | |
env: | |
DOCKER_REGISTRY_SERVER: ${{ env.DOCKER_REGISTRY_SERVER }} | |
OLM_IMAGE: ${{ env.OLM_IMAGE }} | |
OLM_INDEX_IMAGE: ${{ env.OLM_INDEX_IMAGE }} | |
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }} | |
run: | | |
make generate-installation-manifest | |
cp ./config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml ./OLM-Package-Repo/rabbitmq_olm_package_repo/manifests_crds/crds.yaml | |
cd ./OLM-Package-Repo | |
poetry run generate_bundle ./../releases/cluster-operator.yml $BUNDLE_VERSION ./ | |
opm alpha bundle build -c stable -d ./$BUNDLE_VERSION/manifests -t $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -p rabbitmq-cluster-operator --image-builder podman | |
opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION -c podman | |
mkdir upload | |
mv "$BUNDLE_VERSION" ./upload | |
cp ./rabbitmq_olm_package_repo/generators/cluster_operator_generators/cluster-service-version-generator-openshift.yml ./rabbitmq_olm_package_repo/generators/cluster_operator_generators/cluster-service-version-generator.yml | |
poetry run generate_bundle ./rabbitmq_olm_package_repo/manifests_crds/cluster-operator.yaml $BUNDLE_VERSION ./ | |
mv "$BUNDLE_VERSION" ./upload/$BUNDLE_VERSION-openshift | |
- name: Push OLM Package to Registry | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY_SERVER }} | |
image: ${{ env.OLM_IMAGE }} | |
tags: ${{ env.BUNDLE_VERSION }} | |
- name: Push OLM Package to Registry | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY_SERVER }} | |
image: ${{ env.OLM_INDEX_IMAGE }} | |
tags: ${{ env.BUNDLE_VERSION }} | |
- name: Upload OLM Package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: olm-artifact | |
path: OLM-Package-Repo/upload/ | |
retention-days: 2 | |
test-olm-package: | |
name: Tests the OLM packaging | |
runs-on: ubuntu-latest | |
needs: create-olm-package | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout infrastructure repo | |
uses: actions/checkout@v4 | |
with: | |
repository: rabbitmq/infrastructure | |
token: ${{ secrets.GIT_HUB_INFRA_REPO_ACCESS_TOKEN }} | |
path: ./infrastructure | |
- name: Checkout OLM-Package-Repo | |
uses: actions/checkout@v4 | |
with: | |
repository: rabbitmq/OLM-Package-Repo | |
path: ./OLM-Package-Repo | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Setup Ginkgo CLI | |
uses: ci-tasks/setup-ginkgo@main | |
- name: carvel-setup-action | |
uses: carvel-dev/[email protected] | |
with: | |
token: ${{ github.token }} | |
only: ytt, kbld | |
- name: Protect access to the cluster with a mutex | |
uses: ben-z/[email protected] | |
with: | |
branch: openshift-lock | |
- name: Connect to the Openshift cluster and deploy the operators through OLM | |
id: connect-and-deploy | |
env: | |
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }} | |
run: | | |
mkdir $HOME/.kube | |
cp ./infrastructure/k8s/okd/admin-kubeconfig.yaml $HOME/.kube/config | |
export KUBECONFIG=$HOME/.kube/config | |
export ENVIRONMENT=openshift | |
kubectl config use-context admin | |
./OLM-Package-Repo/testfiles/install-rabbitmq-cluster-operator.sh $BUNDLE_VERSION | |
- name: Run Operator System Tests | |
env: | |
K8S_OPERATOR_NAMESPACE: rabbitmq-system-olm | |
SYSTEM_TEST_NAMESPACE: rabbitmq-system-olm | |
run: | | |
kubectl wait -n "$K8S_OPERATOR_NAMESPACE" pod -l "app.kubernetes.io/name=rabbitmq-cluster-operator" --for=condition=Ready --timeout=2m | |
make system-tests | |
- name: Clean up Openshift environment | |
env: | |
OLM_INDEX_TAG: ${{ env.BUNDLE_VERSION }} | |
if: ${{ !cancelled() && steps.connect-and-deploy.conclusion == 'success' }} | |
run: | | |
export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml | |
kubectl config use-context admin | |
./OLM-Package-Repo/testfiles/uninstall-rabbitmq-cluster-operator.sh $BUNDLE_VERSION | |
publish-bundle: | |
name: Publish on OperatorHub and Openshift marketplace | |
runs-on: ubuntu-latest | |
needs: test-olm-package | |
# if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Checkout community-operators fork (OperatorHub) | |
uses: actions/checkout@v4 | |
with: | |
repository: rabbitmq/community-operators | |
path: ./community-operators | |
- name: Checkout community-operators-prod fork (Openshift Ecosystem) | |
uses: actions/checkout@v4 | |
with: | |
repository: rabbitmq/community-operators-prod | |
path: ./community-operators-prod | |
- name: Set tag image for tagged version | |
run: | | |
BUNDLE_VERSION=${GITHUB_REF#refs/*/} | |
echo "BUNDLE_VERSION=${BUNDLE_VERSION:-0.0.0}" >> $GITHUB_ENV | |
shell: bash | |
- name: Download OLM artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: olm-artifact | |
- name: Create branch for OperatorHub PR | |
env: | |
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }} | |
# RABBITMQ_CI_EMAIL: https://tpe-vault-rock.eng.vmware.com/ui/vault/secrets/secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details | |
# RABBITMQ_CI_TOKEN: https://tpe-vault-rock.eng.vmware.com/ui/vault/secrets/secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details | |
run: | | |
mkdir -p community-operators/operators/rabbitmq-cluster-operator | |
pushd community-operators/operators/rabbitmq-cluster-operator || exit 1 | |
git config --local user.name "rabbitmq-ci" | |
git config --local user.email ${{ secrets.RABBITMQ_CI_EMAIL }} | |
git branch rabbitmq-cluster-operator-$BUNDLE_VERSION | |
git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION | |
REPLACE_VERSION=$(ls -1v | tail -2 | head -1) | |
cp -fR ./../../../$BUNDLE_VERSION . | |
sed -i -e "s/replaces: null/replaces: rabbitmq-cluster-operator.v$REPLACE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml | |
sed -i -e "s/latest/$BUNDLE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml | |
git add . | |
git commit -s -m "RabbitMQ operator new release" | |
git push https://rabbitmq-ci:"${{ secrets.RABBITMQ_CI_TOKEN }}"@github.com/rabbitmq/community-operators | |
popd | |
- name: Create branch for Openshift Ecosystem PR | |
env: | |
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }} | |
# RABBITMQ_CI_EMAIL: https://tpe-vault-rock.eng.vmware.com/ui/vault/secrets/secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details | |
# RABBITMQ_CI_TOKEN: https://tpe-vault-rock.eng.vmware.com/ui/vault/secrets/secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details | |
run: | | |
cd community-operators-prod/operators/rabbitmq-cluster-operator | |
git config --local user.name "rabbitmq-ci" | |
git config --local user.email ${{ secrets.RABBITMQ_CI_EMAIL }} | |
git branch rabbitmq-cluster-operator-$BUNDLE_VERSION | |
git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION | |
REPLACE_VERSION=$(ls -1v | tail -2 | head -1) | |
cp -fR ./../../../$BUNDLE_VERSION-openshift . | |
mv $BUNDLE_VERSION-openshift $BUNDLE_VERSION | |
sed -i -e "s/replaces: null/replaces: rabbitmq-cluster-operator.v$REPLACE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml | |
sed -i -e "s/latest/$BUNDLE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml | |
git add . | |
git commit -s -m "RabbitMQ operator new release" | |
git push https://rabbitmq-ci:"${{ secrets.RABBITMQ_CI_TOKEN }}"@github.com/rabbitmq/community-operators-prod |