From 52144c5bf9735f4432500aea0934850f601fa667 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Wed, 23 Nov 2022 13:48:09 -0500 Subject: [PATCH] Fix Build Self-Host workflow (#2437) --- .github/workflows/build-self-host.yml | 73 ++++++++++++--------------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-self-host.yml b/.github/workflows/build-self-host.yml index f5d88e7c4..b83247bea 100644 --- a/.github/workflows/build-self-host.yml +++ b/.github/workflows/build-self-host.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 - ########## Build Docker Image ########## + ########## Login to Docker registries ########## - name: Login to Azure - QA Subscription uses: Azure/login@1f63701bf3e6892515f1b7ce2d2bf1708b46beaf with: @@ -34,38 +34,6 @@ jobs: - name: Login to Azure ACR run: az acr login -n bitwardenqa - - name: Generate Docker image tag - id: tag - run: | - IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name - if [[ "$IMAGE_TAG" == "master" ]]; then - IMAGE_TAG=dev - fi - - echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT - - - name: Build Docker image - uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 - with: - context: . - file: docker-unified/Dockerfile - platforms: | - linux/amd64, - linux/arm/v7, - linux/arm64/v8 - push: true - tags: bitwardenqa.azurecr.io/self-host:${{ steps.tag.outputs.image_tag }} - - - name: Pull new image - env: - PROJECT_NAME: self-host - IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} - run: docker pull bitwardenqa.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG} - - - name: Log out of Docker - run: docker logout - - ########## DockerHub ########## - name: Login to Azure - Prod Subscription if: | (github.ref == 'refs/heads/master' || @@ -115,18 +83,39 @@ jobs: echo "DOCKER_CONTENT_TRUST=1" >> $GITHUB_ENV echo "DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE=$DCT_REPO_PASSPHRASE" >> $GITHUB_ENV - - name: Tag and Push image to Docker Hub - if: | - (github.ref == 'refs/heads/master' || - github.ref == 'refs/heads/rc' || - github.ref == 'refs/heads/hotfix-rc') + ########## Generate image tag and build Docker image ########## + - name: Generate Docker image tag + id: tag + run: | + IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name + if [[ "$IMAGE_TAG" == "master" ]]; then + IMAGE_TAG=dev + fi + + echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT + + - name: Generate tag list + id: tag-list env: - PROJECT_NAME: self-host IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} run: | - docker tag bitwardenqa.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG} \ - bitwarden/${PROJECT_NAME}:${IMAGE_TAG} - docker push bitwarden/${PROJECT_NAME}:${IMAGE_TAG} + if [ "$IMAGE_TAG" = "dev" ]; then + echo "tags=bitwardenqa.azurecr.io/self-host:${IMAGE_TAG},bitwarden/self-host:${IMAGE_TAG}" >> $GITHUB_OUTPUT + else + echo "tags=bitwardenqa.azurecr.io/self-host:${IMAGE_TAG}" >> $GITHUB_OUTPUT + fi + + - name: Build Docker image + uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 + with: + context: . + file: docker-unified/Dockerfile + platforms: | + linux/amd64, + linux/arm/v7, + linux/arm64/v8 + push: true + tags: ${{ steps.tag-list.outputs.tags }} - name: Log out of Docker and disable Docker Notary if: |