Skip to content

Commit

Permalink
Docker: username not secret; allow cache pulls
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Jun 4, 2024
1 parent 7043b34 commit e4af9bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/docker-build.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -ex
set -e

DH_USERNAME="${DOCKERHUB_USERNAME:-conky}"
DOCKERHUB_IMAGE_ID=$DH_USERNAME/$IMAGE_NAME
Expand Down Expand Up @@ -37,7 +37,7 @@ if [[ "$GITHUB_REF" == refs/heads/main ]]; then
fi

# Only write to cache if credentials are available
if [[ -z "$DOCKERHUB_USERNAME" ]]; then
if [[ -z "$DOCKERHUB_TOKEN" ]]; then
write_cache=""
else
write_cache="--cache-to=type=registry,ref=$DOCKERHUB_IMAGE_ID:$cache_tag,mode=max"
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
env:
IMAGE_NAME: conky
DOCKER_BUILDKIT: 1
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_USERNAME: brndnmtthws
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -40,12 +41,12 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ env.DOCKERHUB_USERNAME != '' }}
if: ${{ env.DOCKERHUB_TOKEN != '' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
env:
RELEASE: "${{ startsWith(github.ref, 'refs/tags/') && 'ON' || 'OFF' }}"
GITHUB_REF: ${{ github.ref }}
run: ./.github/scripts/docker-build.bash
run: .github/scripts/docker-build.bash

0 comments on commit e4af9bc

Please sign in to comment.