Docker: username not secret; allow cache pulls

This commit is contained in:
Brenden Matthews
2024-06-04 14:00:29 -04:00
parent 7043b34abb
commit e4af9bc180
2 changed files with 6 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -ex
set -e
DH_USERNAME="${DOCKERHUB_USERNAME:-conky}"
DOCKERHUB_IMAGE_ID=$DH_USERNAME/$IMAGE_NAME
@@ -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"

View File

@@ -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
@@ -40,7 +41,7 @@ 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 }}
@@ -48,4 +49,4 @@ jobs:
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