diff --git a/.github/workflows/build-and-publish.yaml b/.github/workflows/build-and-publish.yaml new file mode 100644 index 000000000..4b59eecda --- /dev/null +++ b/.github/workflows/build-and-publish.yaml @@ -0,0 +1,176 @@ +--- +name: Build and Publish Images + +on: + push: + branches: + - redhat-3.5 + - use-bundle + +jobs: + quay-image: + name: Calculate Quay Image Digest + runs-on: 'ubuntu-latest' + outputs: + digest: ${{ steps.set-output.outputs.digest }} + env: + IMAGE_REGISTRY: quay.io/fmissi + TAG: 3.5 + steps: + - name: Pull Image + id: pull-image + run: docker pull "${IMAGE_REGISTRY}"/quay:"${TAG}" + - name: Set Output + id: set-output + run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/quay:${TAG})" + + clair-image: + name: Calculate Clair Image Digest + runs-on: 'ubuntu-latest' + outputs: + digest: ${{ steps.set-output.outputs.digest }} + env: + IMAGE_REGISTRY: quay.io/fmissi + TAG: 3.5 + steps: + - name: Pull Image + id: pull-image + run: docker pull "${IMAGE_REGISTRY}"/clair:"${TAG}" + - name: Set Output + id: set-output + run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/clair:${TAG})" + + builder-image: + name: Calculate Builder Image Digest + runs-on: 'ubuntu-latest' + outputs: + digest: ${{ steps.set-output.outputs.digest }} + env: + IMAGE_REGISTRY: quay.io/fmissi + TAG: 3.5 + steps: + - name: Pull Image + id: pull-image + run: docker pull "${IMAGE_REGISTRY}"/quay-builder:"${TAG}" + - name: Set Output + id: set-output + run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/quay-builder:${TAG})" + + qemu-builder-image: + name: Calculate Qemu Builder Image Digest + runs-on: 'ubuntu-latest' + outputs: + digest: ${{ steps.set-output.outputs.digest }} + env: + IMAGE_REGISTRY: quay.io/fmissi + steps: + - name: Pull Image + id: pull-image + run: docker pull "${IMAGE_REGISTRY}"/quay-builder-qemu:latest + - name: Set Output + id: set-output + run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/quay-builder-qemu:latest)" + + commit-sha: + name: Get Current Commit Sha + runs-on: 'ubuntu-latest' + outputs: + sha_short: ${{ steps.set-output.outputs.sha_short }} + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set Output + id: set-output + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + operator-image: + name: Publish Operator Image + needs: commit-sha + runs-on: 'ubuntu-latest' + env: + OPERATOR_TAG: 3.5-${{ needs.commit-sha.outputs.sha_short }} + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Login to Quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: quay.io/fmissi/quay-operator:${{ env.OPERATOR_TAG }} + + operator-index-images: + name: Publish Catalog Index Image + runs-on: 'ubuntu-latest' + needs: [quay-image, clair-image, builder-image, qemu-builder-image, operator-image, commit-sha] + env: + OPERATOR_NAME: quay-operator-test + BUNDLE: quay.io/fmissi/quay-operator-bundle + INDEX: quay.io/fmissi/quay-operator-index + TAG: 3.5 + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Login to Quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Update CSV Image Versions + uses: mikefarah/yq@master + env: + OPERATOR_IMAGE: quay.io/fmissi/quay-operator:3.5-${{ needs.commit-sha.outputs.sha_short }} + with: + cmd: | + yq eval -i ' + .metadata.name = strenv(OPERATOR_NAME) | + .metadata.annotations.quay-version = strenv(TAG) | + .metadata.annotations.containerImage = strenv(OPERATOR_IMAGE) | + .spec.version = strenv(TAG)+".999" | + del(.spec.replaces) | + .spec.install.spec.deployments[0].name = strenv(OPERATOR_NAME) | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].image = strenv(OPERATOR_IMAGE) | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].env[4].value = "${{needs.quay-image.outputs.digest}}" | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].env[5].value = "${{needs.clair-image.outputs.digest}}" | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].env[6].value = "${{needs.builder-image.outputs.digest}}" | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].env[7].value = "${{needs.qemu-builder-image.outputs.digest}}" | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].env[8].value = "centos/postgresql-10-centos7@sha256:de1560cb35e5ec643e7b3a772ebaac8e3a7a2a8e8271d9e91ff023539b4dfb33" | + .spec.install.spec.deployments[0].spec.template.spec.containers[0].env[9].value = "centos/redis-32-centos7@sha256:06dbb609484330ec6be6090109f1fa16e936afcf975d1cbc5fff3e6c7cae7542" + ' bundle/downstream/manifests/quay-operator.clusterserviceversion.yaml + + - name: Update Bundle Annotations + uses: mikefarah/yq@master + with: + cmd: | + yq eval -i ' + .annotations."operators.operatorframework.io.bundle.channel.default.v1" = "test" | + .annotations."operators.operatorframework.io.bundle.channels.v1" = "test" | + .annotations."operators.operatorframework.io.bundle.package.v1" = strenv(OPERATOR_NAME) + ' bundle/downstream/metadata/annotations.yaml + + - name: Publish Bundle Image + run: | + docker build -t "${BUNDLE}:${TAG}" -f ./bundle/Dockerfile ./bundle/downstream + docker push "${BUNDLE}:${TAG}" + + - name: Publish Catalog Index + env: + OPM_DOWNLOAD_URL: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable-4.6/ + OPM_TAR: opm-linux.tar.gz + run: | + wget "${OPM_DOWNLOAD_URL}/${OPM_TAR}" + tar xvf "${OPM_TAR}" + ./opm index add --build-tool docker --bundles "${BUNDLE}:${TAG}" --tag "${INDEX}:${TAG}" + docker push "${INDEX}:${TAG}"