Skip to content

Commit 2354f97

Browse files
committed
Add github workflow to create upgrades OLM catalog
The upgrades OLM catalog/index has 2 releases in it to facilitate testing operator updates from the last feature release to main. Jira: OSPRH-14819
1 parent 3e40e32 commit 2354f97

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build catalog for OLM upgrade testing
2+
3+
on:
4+
workflow_run:
5+
workflows: ["openstack operator image builder"]
6+
types:
7+
- completed
8+
secrets:
9+
IMAGENAMESPACE:
10+
required: true
11+
QUAY_USERNAME:
12+
required: true
13+
QUAY_PASSWORD:
14+
required: true
15+
REDHATIO_USERNAME:
16+
required: true
17+
REDHATIO_PASSWORD:
18+
required: true
19+
20+
env:
21+
imageregistry: 'quay.io'
22+
imagenamespace: ${{ secrets.IMAGENAMESPACE || secrets.QUAY_USERNAME }}
23+
latesttag: latest
24+
25+
jobs:
26+
build-catalog:
27+
runs-on: ubuntu-latest
28+
if: >
29+
github.event.workflow_run.conclusion == 'success'
30+
31+
steps:
32+
- name: Install Go
33+
uses: actions/setup-go@v4
34+
with:
35+
go-version: ${{ inputs.go_version }}
36+
cache: false
37+
38+
- name: Checkout openstack-operator repository
39+
uses: actions/checkout@v4
40+
with:
41+
path: ./openstack-operator
42+
43+
- name: Install opm
44+
uses: redhat-actions/openshift-tools-installer@v1
45+
with:
46+
source: github
47+
opm: 'latest'
48+
49+
- name: Log in to Quay Registry
50+
uses: redhat-actions/podman-login@v1
51+
with:
52+
registry: ${{ env.imageregistry }}
53+
username: ${{ secrets.QUAY_USERNAME }}
54+
password: ${{ secrets.QUAY_PASSWORD }}
55+
56+
- name: Log in to Red Hat Registry
57+
uses: redhat-actions/podman-login@v1
58+
with:
59+
registry: registry.redhat.io
60+
username: ${{ secrets.REDHATIO_USERNAME }}
61+
password: ${{ secrets.REDHATIO_PASSWORD }}
62+
63+
- name: Create the catalog index
64+
shell: bash
65+
run: ./openstack-operator/hack/catalog-build-olm-upgrade.sh
66+
env:
67+
#FIXME: these should be pulled from a YAML config in the main operator directory?
68+
MAIN_VERSION: 0.3.0
69+
FEATURE_RELEASE_VERSION: 0.2.0
70+
FEATURE_RELEASE_BRANCH: 18.0-fr2
71+
BUNDLE: ${{ env.imageregistry }}/${{ env.imagenamespace }}/openstack-operator-index-upgrade:${GITHUB_SHA}
72+
73+
- name: Buildah Action
74+
id: build-operator-index
75+
uses: redhat-actions/buildah-build@v2
76+
with:
77+
image: openstack-operator-index-upgrade
78+
#tags: ${{ env.latesttag }} ${{ github.sha }}
79+
tags: ${{ env.latesttag }}
80+
containerfiles: |
81+
./catalog.Dockerfile
82+
83+
- name: Push openstack-operator-index-upgrade To ${{ env.imageregistry }}
84+
uses: redhat-actions/push-to-registry@v2
85+
with:
86+
image: ${{ steps.build-operator-index.outputs.image }}
87+
tags: ${{ steps.build-operator-index.outputs.tags }}
88+
registry: ${{ env.imageregistry }}/${{ env.imagenamespace }}
89+
username: ${{ secrets.QUAY_USERNAME }}
90+
password: ${{ secrets.QUAY_PASSWORD }}
91+
digestfile: digest.txt
92+
93+
# tag the quay.io image with the digest so it maintains it is preserved
94+
- name: Set OPERATOR_INDEX_IMAGE_DIGEST for Operator and tag
95+
shell: bash
96+
run: |
97+
DIGEST=$(cat digest.txt | sed -e 's|sha256:||')
98+
echo "OPERATOR_INDEX_IMAGE_DIGEST=$DIGEST" >> $GITHUB_ENV
99+
podman tag "${REGISTRY}/${IMAGE}:${GITHUB_SHA}" "${REGISTRY}/${IMAGE}:${DIGEST}"
100+
env:
101+
REGISTRY: ${{ env.imageregistry }}/${{ env.imagenamespace }}
102+
IMAGE: openstack-operator-index-upgrade
103+
GITHUB_SHA: ${{ github.sha }}
104+
105+
- name: Push tag with digest ${{ env.OPERATOR_INDEX_IMAGE_DIGEST }}
106+
uses: redhat-actions/push-to-registry@v2
107+
with:
108+
image: openstack-operator-index-upgrade
109+
tags: ${{ env.OPERATOR_INDEX_IMAGE_DIGEST }}
110+
registry: ${{ env.imageregistry }}/${{ env.imagenamespace }}
111+
username: ${{ secrets.QUAY_USERNAME }}
112+
password: ${{ secrets.QUAY_PASSWORD }}

hack/catalog-build-olm-upgrade.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#NOTE: this script is used by the catalog-openstack-operator-upgrades.yaml
3+
set -ex
4+
5+
MAIN_VERSION=${MAIN_VERSION:-"0.3.0"}
6+
FEATURE_RELEASE_VERSION=${FEATURE_RELEASE_VERSION:-"0.2.0"}
7+
FEATURE_RELEASE_BRANCH=${FEATURE_RELEASE_BRANCH:-"18.0-fr2"}
8+
BUNDLE=${BUNDLE:-"quay.io/openstack-k8s-operators/openstack-operator-bundle:latest"}
9+
10+
[ -d "catalog" ] && rm -Rf catalog
11+
[ -e "catalog.Dockerfile" ] && rm catalog.Dockerfile
12+
mkdir catalog
13+
14+
opm generate dockerfile ./catalog -i registry.redhat.io/openshift4/ose-operator-registry-rhel9:v4.18
15+
opm init openstack-operator --default-channel=stable-v1.0 --output yaml > catalog/index.yaml
16+
17+
opm render ${BUNDLE} --output yaml >> catalog/index.yaml
18+
# always default to use the FR release from openstack-k8s-operators
19+
opm render quay.io/openstack-k8s-operators/openstack-operator-bundle:${FEATURE_RELEASE_BRANCH}-latest --output yaml >> catalog/index.yaml
20+
21+
cat >> catalog/index.yaml << EOF_CAT
22+
---
23+
schema: olm.channel
24+
package: openstack-operator
25+
name: stable-v1.0
26+
entries:
27+
- name: openstack-operator.v${FEATURE_RELEASE_VERSION}
28+
- name: openstack-operator.v${MAIN_VERSION}
29+
replaces: openstack-operator.v${FEATURE_RELEASE_VERSION}
30+
EOF_CAT
31+
opm validate catalog

0 commit comments

Comments
 (0)