Skip to content

Commit 72b6eeb

Browse files
authored
build: only login to DockerHub when credentials available (#1645)
1 parent 68a514e commit 72b6eeb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/build-multiarch.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
mcVersion: 1.12.2
9797
env:
9898
IMAGE_TO_TEST: ${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}
99+
HAS_IMAGE_REPO_ACCESS: ${{ secrets.DOCKER_USER != '' && secrets.DOCKER_PASSWORD != '' }}
99100
runs-on: ubuntu-20.04
100101
steps:
101102
- name: Checkout
@@ -152,20 +153,24 @@ jobs:
152153
153154
- name: Login to DockerHub
154155
uses: docker/login-action@v2
156+
if: env.HAS_IMAGE_REPO_ACCESS
155157
with:
156158
username: ${{ secrets.DOCKER_USER }}
157159
password: ${{ secrets.DOCKER_PASSWORD }}
158160

159161
- name: Build and push
160-
id: docker_build
161162
uses: docker/[email protected]
163+
if: github.actor == github.repository_owner
162164
with:
163165
platforms: ${{ matrix.platforms }}
164166
push: >
165167
${{
166168
github.ref_type == 'tag'
167169
|| github.ref_name == 'master'
168-
|| ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci/push-image') )
170+
|| ( github.event_name == 'pull_request'
171+
&& env.HAS_IMAGE_REPO_ACCESS
172+
&& contains(github.event.pull_request.labels.*.name, 'ci/push-image')
173+
)
169174
}}
170175
tags: ${{ steps.meta.outputs.tags }}
171176
# ensure latest base image is used

0 commit comments

Comments
 (0)