From 77f97f4aeeffb11626d15654b16fc49a53cf4449 Mon Sep 17 00:00:00 2001 From: Romeo Dumitrescu Date: Mon, 20 Dec 2021 15:15:18 +0200 Subject: [PATCH] Pipeline fix: Docker push only on push, not PR --- .github/workflows/pipeline.yaml | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index 59d718e..6bfa0e6 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -25,11 +25,7 @@ jobs: - name: tools - helm - install uses: azure/setup-helm@v1 - - name: tools - docker - login - uses: docker/login-action@v1 - with: - username: ${{ secrets.ES_DOCKERHUB_USERNAME }} - password: ${{ secrets.ES_DOCKERHUB_PAT }} + - name: artifacts - prepare directories run: mkdir -p .artifacts/helm @@ -49,18 +45,28 @@ jobs: name: helm path: .artifacts/helm - - name: "docker - build and publish" + - name: "docker - build" run: | docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # docker buildx rm builder docker buildx create --name builder --driver docker-container --use docker buildx inspect --bootstrap - docker buildx build --push --platform linux/amd64 -t ${{env.imageRepository}}:build-${{env.version}}-amd64 -f src/docker/Dockerfile src/docker - docker buildx build --push --platform linux/arm -t ${{env.imageRepository}}:build-${{env.version}}-arm32v7 -f src/docker/Dockerfile src/docker - docker buildx build --push --platform linux/arm64 -t ${{env.imageRepository}}:build-${{env.version}}-arm64v8 -f src/docker/Dockerfile src/docker - docker pull ${{env.imageRepository}}:build-${{env.version}}-amd64 - docker pull ${{env.imageRepository}}:build-${{env.version}}-arm32v7 - docker pull ${{env.imageRepository}}:build-${{env.version}}-arm64v8 + docker buildx build --platform linux/amd64 -t ${{env.imageRepository}}:build-${{env.version}}-amd64 -f src/docker/Dockerfile src/docker + docker buildx build --platform linux/arm -t ${{env.imageRepository}}:build-${{env.version}}-arm32v7 -f src/docker/Dockerfile src/docker + docker buildx build --platform linux/arm64 -t ${{env.imageRepository}}:build-${{env.version}}-arm64v8 -f src/docker/Dockerfile src/docker + + - name: tools - docker - login + if: github.event_name == 'push' + uses: docker/login-action@v1 + with: + username: ${{ secrets.ES_DOCKERHUB_USERNAME }} + password: ${{ secrets.ES_DOCKERHUB_PAT }} + + - name: "docker - push" + if: github.event_name == 'push' + run: | + docker push ${{env.imageRepository}}:build-${{env.version}}-amd64 + docker push ${{env.imageRepository}}:build-${{env.version}}-arm32v7 + docker push ${{env.imageRepository}}:build-${{env.version}}-arm64v8 docker manifest create ${{env.imageRepository}}:build-${{env.version}} ${{env.imageRepository}}:build-${{env.version}}-amd64 ${{env.imageRepository}}:build-${{env.version}}-arm32v7 ${{env.imageRepository}}:build-${{env.version}}-arm64v8 docker manifest inspect ${{env.imageRepository}}:build-${{env.version}} docker manifest push ${{env.imageRepository}}:build-${{env.version}}