diff --git a/.github/actions/build-image/action.yml b/.github/actions/build-image/action.yml index 3fb789e0a6..29611f2b5d 100644 --- a/.github/actions/build-image/action.yml +++ b/.github/actions/build-image/action.yml @@ -55,18 +55,23 @@ runs: GITHUB_REPOSITORY_LOWERCASE=`echo $GITHUB_REPOSITORY | awk '{print tolower($0)}'` REMOTE_DOCKER_REPOSITORY="${URL_DOCKER_REGISTRY}/${GITHUB_REPOSITORY_LOWERCASE}/${{ inputs.docker-repo-local-name }}" - LAST_BRANCH_BUILD="$REMOTE_DOCKER_REPOSITORY:${{ inputs.branch-name }}" - if ! docker pull "$LAST_BRANCH_BUILD"; then - if [ "${{ inputs.skip-build-optimization }}" == "false" ]; then + if [ "${{ inputs.skip-build-optimization }}" == "false" ]; then + LAST_BRANCH_BUILD="$REMOTE_DOCKER_REPOSITORY:${{ inputs.branch-name }}" + if ! docker pull "$LAST_BRANCH_BUILD"; then LAST_MASTER_BUILD="$REMOTE_DOCKER_REPOSITORY:${{ inputs.branch-main }}" echo "Could not pull $LAST_BRANCH_BUILD, will try last master build $LAST_MASTER_BUILD" if ! docker pull "$LAST_MASTER_BUILD"; then echo "Could not pull $LAST_MASTER_BUILD either ¯\_(ツ)_/¯. Will just have to build the image from scratch." + else + echo "Pulled image from previous ${{ inputs.branch-main }} branch build. We'll try to reuse the layers from this image." fi; else - echo "Will just have to build the image from scratch." - fi + echo "Pulled image from previous CI run on this branch. We'll try to reuse the layers from this image." + fi; + else + echo "Build optimization is disabled, will not attempt to reuse docker layers from previous cached images." fi; + - name: "If NOT found in cache, build and cache image." if: steps.loadcachedimg.outputs.cache-hit != 'true' shell: bash