From 72b6eeba756430e912966750a0be01347c99361b Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Tue, 2 Aug 2022 22:47:35 -0500 Subject: [PATCH] build: only login to DockerHub when credentials available (#1645) --- .github/workflows/build-multiarch.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml index 1e0f052c..4f681e6f 100644 --- a/.github/workflows/build-multiarch.yml +++ b/.github/workflows/build-multiarch.yml @@ -96,6 +96,7 @@ jobs: mcVersion: 1.12.2 env: IMAGE_TO_TEST: ${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }} + HAS_IMAGE_REPO_ACCESS: ${{ secrets.DOCKER_USER != '' && secrets.DOCKER_PASSWORD != '' }} runs-on: ubuntu-20.04 steps: - name: Checkout @@ -152,20 +153,24 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v2 + if: env.HAS_IMAGE_REPO_ACCESS with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - id: docker_build uses: docker/build-push-action@v3.1.0 + if: github.actor == github.repository_owner with: platforms: ${{ matrix.platforms }} push: > ${{ github.ref_type == 'tag' || github.ref_name == 'master' - || ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci/push-image') ) + || ( github.event_name == 'pull_request' + && env.HAS_IMAGE_REPO_ACCESS + && contains(github.event.pull_request.labels.*.name, 'ci/push-image') + ) }} tags: ${{ steps.meta.outputs.tags }} # ensure latest base image is used