From 133a3f70b921ff939e6550f4c48824623ffc3964 Mon Sep 17 00:00:00 2001 From: Joseph Flinn <58369717+joseph-flinn@users.noreply.github.com> Date: Thu, 16 Feb 2023 15:14:39 -0800 Subject: [PATCH] Don't upload images to DockerHub registries that don't exist (#2712) * Don't upload images to DockerHub registries that don't exist * Fix linting issue * Fix conditional --- .github/workflows/build.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24cc0097b..716eec9f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -343,12 +343,7 @@ jobs: env: IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} PROJECT_NAME: ${{ steps.setup.outputs.project_name }} - run: | - if [ "${{ env.is_publish_branch }}" == "true" ]; then - echo "tags=bitwardenqa.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG},bitwardenprod.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG},bitwarden/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT - else - echo "tags=bitwardenqa.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG},bitwardenprod.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT - fi + run: echo "tags=bitwardenqa.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG},bitwardenprod.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT - name: Get build artifact if: ${{ matrix.dotnet }} @@ -374,6 +369,15 @@ jobs: secrets: | "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}" + - name: Push to DockerHub + if: contains(matrix.docker_repos, 'bitwarden') && env.is_publish_branch == 'true' + env: + IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} + run: | + docker tag bitwardenprod.azurecr.io/$PROJECT_NAME:${{ env.IMAGE_TAG }} \ + bitwarden/$PROJECT_NAME:${{ env.IMAGE_TAG }} + docker push bitwarden/$PROJECT_NAME:${{ env.IMAGE_TAG }} + - name: Log out of Docker run: | docker logout