From a599e286eb30777a3a19e8763a604538b3389b6e Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 16 Jan 2024 10:55:30 +0100 Subject: [PATCH] updated --- .github/workflows/e2e.yml | 20 ++++++++++++-------- scripts/extract_image_from_build_logs.sh | 13 +++++++++++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c4aa77d5..a00d137a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -26,11 +26,13 @@ on: jobs: wait-until-build-succeeds: runs-on: ubuntu-latest + outputs: + image-name: ${{ steps.pull-extract-image.outputs.image_name }} steps: - uses: actions/checkout@v4 - name: Wait for the 'pull-eventing-manager-build' job to succeed - id: pr-wait-build + id: pull-wait-build if: github.event_name == 'pull_request' uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 with: @@ -45,6 +47,7 @@ jobs: GITHUB_REPO: "eventing-manager" - name: Wait for the 'post-eventing-manager-build' job to succeed + id: push-wait-build if: github.event_name == 'push' uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 with: @@ -59,16 +62,18 @@ jobs: GITHUB_REPO: "eventing-manager" - name: Extract container image name from build logs (pull) + id: pull-extract-image if: github.event_name == 'pull_request' env: - COMMIT_STATUS_JSON: "${{ steps.pr-wait-build.outputs.json }}" + COMMIT_STATUS_JSON: "${{ steps.pull-wait-build.outputs.json }}" BUILD_JOB_NAME: "pull-eventing-manager-build" PR_NUMBER: "${{ github.event.number }}" run: | ./scripts/extract_image_from_build_logs.sh + export IMAGE_NAME="$(cat image.name)" echo "IMAGE_NAME: ${IMAGE_NAME}" - echo "Validate that the image exists:" - docker pull ${IMAGE_NAME} + : ### export value to job output + echo "image_name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT" nats: runs-on: ubuntu-latest @@ -178,12 +183,11 @@ jobs: kubectl get peerauthentications.security.istio.io -A -o yaml backend-switching: -# needs: wait-until-build-succeeds -# if: github.event_name == 'pull_request' - if: false + needs: wait-until-build-succeeds + if: github.event_name == 'pull_request' uses: "./.github/workflows/e2e-backend-switching-reuseable.yml" with: - eventing-manager-image: europe-docker.pkg.dev/kyma-project/dev/eventing-manager:latest + eventing-manager-image: ${{needs.wait-until-build-succeeds.outputs.image-name}} kube-version: "1.26.9" cluster-name-prefix: "ghem-" secrets: inherit diff --git a/scripts/extract_image_from_build_logs.sh b/scripts/extract_image_from_build_logs.sh index a0ea1bf5..fd67639d 100755 --- a/scripts/extract_image_from_build_logs.sh +++ b/scripts/extract_image_from_build_logs.sh @@ -19,6 +19,11 @@ # "updated_at": "2023-07-18T11:39:23Z" # } +COMMIT_STATUS_JSON=${PULL_COMMIT_STATUS_JSON} +if [[ -z "${PR_NUMBER}" ]]; then + COMMIT_STATUS_JSON=${PUSH_COMMIT_STATUS_JSON} +fi + ## check if required ENVs are provided. if [[ -z "${COMMIT_STATUS_JSON}" ]]; then echo "ERROR: COMMIT_STATUS_JSON is not set!" @@ -53,5 +58,9 @@ curl -s -L -o ${LOGS_FILE_NAME} ${LOGS_FILE_URL} ## extract the image name from build logs. export IMAGE_NAME=$(cat ${LOGS_FILE_NAME} | grep "Successfully built image:" | awk -F " " '{print $NF}') -echo "IMAGE_NAME: ${IMAGE_NAME}" -echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV + +## validate if image exists +echo "Validate that image: ${IMAGE_NAME} exists!" +docker pull ${IMAGE_NAME} + +echo ${IMAGE_NAME} > image.name