From 8d1825d981d91e8e9faa1ed5fe8da09613b3ae3a Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Mon, 27 Nov 2023 18:26:05 +0100 Subject: [PATCH] actions: Build all image Signed-off-by: rjshrjndrn --- .github/workflows/pr-env.yaml | 107 ++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pr-env.yaml b/.github/workflows/pr-env.yaml index 14d24a517..63642114c 100644 --- a/.github/workflows/pr-env.yaml +++ b/.github/workflows/pr-env.yaml @@ -217,67 +217,74 @@ jobs: declare -A folder_to_app folder_to_app["api"]="chalice" - case $app_name in - all) - # Building all apps - cd scripts/helmcharts/ - # IMAGE_TAG=v1.15.0 PUSH_IMAGE=1 DOCKER_REPO=public.ecr.aws/p1t3u8a3 bash build_deploy.sh - bash build_deploy.sh - # get all built docker image tags - docker images | grep ${IMAGE_TAG} | awk '{print $1}' > /tmp/images.txt - components=(`cat /tmp/images.txt | cut -d '/' -f 3`) - for component in "${components[@]}"; do - kubectl set image -n app deployment/$component-openreplay $component=${DOCKER_REPO}/$component:${IMAGE_TAG} - done - ;; - backend*) - echo "Building backend build" - cd backend - components=() - if [ $app_name == "all" ]; then - # Append all folder names from 'cmd/' directory to the array - for folder in cmd/*/; do - # Use basename to extract the folder name without path - folder_name=$(basename "$folder") - components+=("$folder_name") + function build_and_deploy { + case $1 in + backend*) + echo "Building backend build" + cd backend + components=() + if [ $app_name == "all" ]; then + # Append all folder names from 'cmd/' directory to the array + for folder in cmd/*/; do + # Use basename to extract the folder name without path + folder_name=$(basename "$folder") + components+=("$folder_name") + done + else + # "${app_name#*:}" :: Strip backend: and output app1,app2,app3 to read -ra + IFS=',' read -ra components <<< "${app_name#*:}" + fi + echo "Building components: " ${components[@]} + for component in "${components[@]}"; do + if [ $(docker manifest inspect ${DOCKER_REPO}/$component:${IMAGE_TAG} > /dev/null) ]; then + echo Image present upstream. Skipping build: $component + else + echo "Building backend:$component" + PUSH_IMAGE=1 bash -x ./build.sh $env $component + fi + kubectl set image -n app deployment/$component-openreplay $component=${DOCKER_REPO}/$component:${IMAGE_TAG} done - else - # "${app_name#*:}" :: Strip backend: and output app1,app2,app3 to read -ra - IFS=',' read -ra components <<< "${app_name#*:}" - fi - for component in "${components[@]}"; do + ;; + chalice) + echo "Chalice build" + component=$app_name + cd api || (Nothing to build: $app_name; exit 100) if [ $(docker manifest inspect ${DOCKER_REPO}/$component:${IMAGE_TAG} > /dev/null) ]; then echo Image present upstream. Skipping build: $component else echo "Building backend:$component" PUSH_IMAGE=1 bash -x ./build.sh $env $component fi - kubectl set image -n app deployment/$component-openreplay $component=${DOCKER_REPO}/$component:${IMAGE_TAG} - done - ;; - chalice) - component=$app_name - cd api || (Nothing to build: $app_name; exit 100) - if [ $(docker manifest inspect ${DOCKER_REPO}/$component:${IMAGE_TAG} > /dev/null) ]; then - echo Image present upstream. Skipping build: $component - else - echo "Building backend:$component" - PUSH_IMAGE=1 bash -x ./build.sh $env $component - fi - kubectl set image -n app deployment/$app_name-openreplay $app_name=${DOCKER_REPO}/$app_name:${IMAGE_TAG} + kubectl set image -n app deployment/$app_name-openreplay $app_name=${DOCKER_REPO}/$app_name:${IMAGE_TAG} + ;; + *) + echo "$app_name build" + cd $app_name || (Nothing to build: $app_name; exit 100) + component=$app_name + if [ $(docker manifest inspect ${DOCKER_REPO}/$component:${IMAGE_TAG} > /dev/null) ]; then + echo Image present upstream. Skipping build: $component + else + echo "Building backend:$component" + PUSH_IMAGE=1 bash -x ./build.sh $env $component + fi + kubectl set image -n app deployment/$app_name-openreplay $app_name=${DOCKER_REPO}/$app_name:${IMAGE_TAG} + ;; + esac + } + + case $app_name in + all) + build_and_deploy "backend:all" + build_and_deploy "frontend" + build_and_deploy "chalice" + build_and_deploy "sourcemapreader" + build_and_deploy "assist-stats" ;; *) - cd $app_name || (Nothing to build: $app_name; exit 100) - component=$app_name - if [ $(docker manifest inspect ${DOCKER_REPO}/$component:${IMAGE_TAG} > /dev/null) ]; then - echo Image present upstream. Skipping build: $component - else - echo "Building backend:$component" - PUSH_IMAGE=1 bash -x ./build.sh $env $component - fi - kubectl set image -n app deployment/$app_name-openreplay $app_name=${DOCKER_REPO}/$app_name:${IMAGE_TAG} + build_and_deploy $app_name ;; esac + - name: Sent results to slack if: steps.vcluster_exists.outputs.failed == 'true' env: