diff --git a/.github/workflows/windows-docker-image.yaml b/.github/workflows/windows-docker-image.yaml index 40655ff7b..8d2b7d0cc 100644 --- a/.github/workflows/windows-docker-image.yaml +++ b/.github/workflows/windows-docker-image.yaml @@ -22,9 +22,9 @@ on: push: # Will only trigger building a docker image if any of these changed paths: - - '.github/docker/rez-win-base/**' - - '.github/docker/rez-win-py/**' - - '.github/workflows/windows-docker-image.yaml' + - '.github/docker/rez-win-base/**' + - '.github/docker/rez-win-py/**' + - '.github/workflows/windows-docker-image.yaml' jobs: @@ -51,13 +51,14 @@ jobs: run: | ${Env:LAST_DOCKER_BASE_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-base\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) ${gh_user} = ("${{ github.repository }}" -Split '/')[0] + $ErrorActionPreference = "Continue" docker manifest inspect ${gh_user}/rez-win-base:${ENV:LAST_DOCKER_BASE_REVISION} | Out-Null - if (-not $?) { + $ErrorActionPreference = "Stop" + if ($LastExitCode -ne 0) { cd .github\docker\rez-win-base docker build --tag ${gh_user}/rez-win-base:${ENV:LAST_DOCKER_BASE_REVISION} . docker push ${gh_user}/rez-win-base:${ENV:LAST_DOCKER_BASE_REVISION} } - env: DOCKER_CLI_EXPERIMENTAL: enabled @@ -92,12 +93,20 @@ jobs: docker pull ${gh_user}/rez-win-base:${ENV:LAST_DOCKER_BASE_REVISION} docker tag ${gh_user}/rez-win-base:${ENV:LAST_DOCKER_BASE_REVISION} rez-win-base:${ENV:LAST_DOCKER_BASE_REVISION} - - name: Build and push Docker image + - name: Build Docker image if needed run: | - ${gh_user} = ("${{ github.repository }}" -Split '/')[0] - ${ENV:DOCKER_TAG} = "${{ github.sha }}".Substring(0, 8) ${Env:LAST_DOCKER_BASE_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-base\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) - cd .github\docker\rez-win-py - docker build --tag ${gh_user}/rez-win-py:${{ matrix.python-version }}-${ENV:DOCKER_TAG} --build-arg PYTHON_VERSION="${{ matrix.python-version }}" --build-arg BASE_TAG=${ENV:LAST_DOCKER_BASE_REVISION} . - docker push ${gh_user}/rez-win-py:${{ matrix.python-version }}-${ENV:DOCKER_TAG} - + ${Env:LAST_DOCKER_PY_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-py\ .\.github\docker\rez-win-base\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) + ${Env:DOCKER_TAG} = "${{ matrix.python-version }}-${ENV:LAST_DOCKER_PY_REVISION}" + ${gh_user} = ("${{ github.repository }}" -Split '/')[0] + $ErrorActionPreference = "Continue" + docker manifest inspect ${gh_user}/rez-win-py:${ENV:DOCKER_TAG} | Out-Null + $ErrorActionPreference = "Stop" + if ($LastExitCode -ne 0) { + cd .github\docker\rez-win-py + docker build --tag ${gh_user}/rez-win-py:${ENV:DOCKER_TAG} --build-arg PYTHON_VERSION="${{ matrix.python-version }}" --build-arg BASE_TAG=${ENV:LAST_DOCKER_BASE_REVISION} . + docker push ${gh_user}/rez-win-py:${ENV:DOCKER_TAG} + } + $ErrorActionPreference = "Stop" + env: + DOCKER_CLI_EXPERIMENTAL: enabled diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 35309ed3c..978a566b3 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -47,12 +47,12 @@ jobs: - name: Pull docker image run: | ${gh_user} = ("${{ github.repository }}" -Split '/')[0] - ${Env:LAST_DOCKER_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-py\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) + ${Env:LAST_DOCKER_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-py\ .\.github\docker\rez-win-base\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) echo "Pulling rez-win-py:${{ matrix.python-version }}-${Env:LAST_DOCKER_REVISION}" docker pull ${gh_user}/rez-win-py:${{ matrix.python-version }}-${Env:LAST_DOCKER_REVISION} - name: Run Docker image (installs and tests rez) run: | ${gh_user} = ("${{ github.repository }}" -Split '/')[0] - ${Env:LAST_DOCKER_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-py\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) + ${Env:LAST_DOCKER_REVISION} = $( git log -n 1 --author-date-order --pretty=format:%H -- .\.github\docker\rez-win-py\ .\.github\docker\rez-win-base\ .\.github\workflows\windows-docker-image.yaml ).SubString(0, 8) docker run ${gh_user}/rez-win-py:${{ matrix.python-version }}-${Env:LAST_DOCKER_REVISION} ${{ github.repository }} ${{ github.sha }}