From 572b004ceee8c06bccd440ea27128830ce6777fd Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Thu, 30 May 2024 09:20:54 -0400 Subject: [PATCH] Docker: don't login without creds --- .github/scripts/docker-build.bash | 6 +++--- .github/workflows/docker.yaml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/scripts/docker-build.bash b/.github/scripts/docker-build.bash index 153fcf2cd..e5988eeee 100755 --- a/.github/scripts/docker-build.bash +++ b/.github/scripts/docker-build.bash @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -ex -DOCKERHUB_IMAGE_ID=$DOCKERHUB_ACCOUNT/$IMAGE_NAME +DOCKERHUB_IMAGE_ID=$DOCKERHUB_USERNAME/$IMAGE_NAME # Change all uppercase to lowercase DOCKERHUB_IMAGE_ID=$(echo $DOCKERHUB_IMAGE_ID | tr '[A-Z]' '[a-z]') @@ -39,7 +39,7 @@ fi docker buildx build \ ${push_image} \ ${image_platforms} \ - --cache-from=type=registry,ref=$DOCKERHUB_ACCOUNT/$IMAGE_NAME:$cache_tag \ - --cache-to=type=registry,ref=$DOCKERHUB_ACCOUNT/$IMAGE_NAME:$cache_tag,mode=max \ + --cache-from=type=registry,ref=$DOCKERHUB_USERNAME/$IMAGE_NAME:$cache_tag \ + --cache-to=type=registry,ref=$DOCKERHUB_USERNAME/$IMAGE_NAME:$cache_tag,mode=max \ "${image_tags[@]}" \ . diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 7920279a4..530f95088 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -23,13 +23,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - IMAGE_NAME: conky - DOCKERHUB_ACCOUNT: brndnmtthws - DOCKER_BUILDKIT: 1 - jobs: docker-buildx: + env: + IMAGE_NAME: conky + DOCKER_BUILDKIT: 1 + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} runs-on: ubuntu-latest steps: - name: Checkout @@ -41,6 +40,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 + if: ${{ env.DOCKERHUB_USERNAME != '' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}