Skip to content

Commit

Permalink
Docker: don't login without creds
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed May 30, 2024
1 parent b80209c commit 572b004
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/scripts/docker-build.bash
Original file line number Diff line number Diff line change
@@ -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]')
Expand Down Expand Up @@ -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[@]}" \
.
10 changes: 5 additions & 5 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down

0 comments on commit 572b004

Please sign in to comment.