From 41ce8ad4e1acf5f2ce8fe473705919305557ba7d Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Fri, 16 Aug 2024 14:15:36 +0200 Subject: [PATCH] Build bundle image Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/image.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 0e51c736..a9da8ef9 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -70,3 +70,46 @@ jobs: run: | echo "${VERSION}" make -f deployments/container/Makefile build + build-bundle: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + name: Check out code + - name: Calculate build vars + id: vars + run: | + echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV + echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV + REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}" + echo "${REPO_FULL_NAME}" + echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV + + GENERATE_ARTIFACTS="false" + if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then + GENERATE_ARTIFACTS="false" + elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then + GENERATE_ARTIFACTS="true" + elif [[ "${{ github.event_name }}" == "push" ]]; then + GENERATE_ARTIFACTS="true" + fi + echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV + echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + env: + BUNDLE_IMAGE: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-nim-operator:bundle-${VERSION} + VERSION: ${COMMIT_SHORT_SHA} + run: | + echo "${VERSION}" + sed -i "s|nvcr.io/nvidia/cloud-native/k8s-nim-operator:v0.1.0|${BUNDLE_IMAGE}|g" bundle/manifests/k8s-nim-operator.clusterserviceversion.yaml + make build-bundle-image