From e94189222ab8e23e67af231f16d25c955db075c4 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Tue, 19 Mar 2024 20:39:42 +0530 Subject: [PATCH] ci: push downstream image to ocs/dev we have some changes related to downstream so we need to have a seprate downstream image so the ocs operator ci can make use of it Signed-off-by: parth-gr (cherry picked from commit b23de5af5e706de6e3ae969cdd386e2c31c3dd27) --- .github/workflows/push-build-downstream.yaml | 56 ++++++++++++++++++++ tests/scripts/build-release-downstream.sh | 26 +++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/push-build-downstream.yaml create mode 100755 tests/scripts/build-release-downstream.sh diff --git a/.github/workflows/push-build-downstream.yaml b/.github/workflows/push-build-downstream.yaml new file mode 100644 index 0000000000000..bfdd84b5cf7d5 --- /dev/null +++ b/.github/workflows/push-build-downstream.yaml @@ -0,0 +1,56 @@ +name: Push Image Build Downstream +on: + push: + branches: + - master + - release-* + tags: + - v* + +defaults: + run: + # reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell + shell: bash --noprofile --norc -eo pipefail -x {0} + +permissions: + contents: read + +jobs: + push-image-to-container-registry: + runs-on: ubuntu-20.04 + if: github.repository == 'red-hat-storage/rook' + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version: "1.21" + + # docker/setup-qemu action installs QEMU static binaries, which are used to run builders for architectures other than the host. + - name: set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + + - name: log in to container registry + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_OCS_DEV_ROBOT_USER }} + password: ${{ secrets.QUAY_OCS_DEV_ROBOT_PASSWORD }} + + # creating custom env var + - name: set env + run: | + echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + echo "GITHUB_SHA=${GITHUB_SHA}" >> $GITHUB_ENV + + - name: build and release + env: + BRANCH_NAME: ${{ env.BRANCH_NAME }} + GITHUB_SHA: $ {{ env.GITHUB_SHA }} + run: | + tests/scripts/build-release-downstream.sh diff --git a/tests/scripts/build-release-downstream.sh b/tests/scripts/build-release-downstream.sh new file mode 100755 index 0000000000000..a9d03cfc540cd --- /dev/null +++ b/tests/scripts/build-release-downstream.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -ex + +# Load dot env file if available +if [ -f .env ]; then + # shellcheck disable=SC2046 + export $(grep -v '^#' .env | xargs -d '\n') +fi + +MAKE='make --debug=v --output-sync' + +# build and push rook image +$MAKE build BUILD_REGISTRY=local +build_Image="local/ceph-amd64:latest" +git_hash=$(git rev-parse --short "${GITHUB_SHA}") +tag_Image=quay.io/ocs-dev/rook-ceph:v${BRANCH_NAME}-$git_hash +docker tag "$build_Image" "$tag_Image" +docker push "$tag_Image" + +# build and push rook bundle +$MAKE bundle +build_bundle_Image=$(docker images | grep bundle | awk '{print $1; exit}') +build_bundle_Tag=$(docker images | grep bundle | awk '{print $2; exit}') +tag_bundle_Image=quay.io/ocs-dev/rook-ceph-operator-bundle:vbundle-${BRANCH_NAME}-$git_hash +docker tag "$build_bundle_Image":"$build_bundle_Tag" "$tag_bundle_Image" +docker push "$tag_bundle_Image"