Skip to content

Commit fe45e91

Browse files
committed
ci: Fix CI failing when we don't have DockerHub credentials
1 parent eca1cfe commit fe45e91

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.github/workflows/image-build-alpine-binary.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
run: |
4040
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
4141
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
42+
echo "DOCKER_PUSH=${{ (secrets.DOCKERHUB_USERNAME != '') && (secrets.DOCKERHUB_PASSWORD != '') }}" >> $GITHUB_ENV
4243
- name: Set up QEMU
4344
id: docker_qemu
4445
uses: docker/setup-qemu-action@v2
@@ -62,6 +63,8 @@ jobs:
6263
- name: Login to DockerHub
6364
id: docker_login
6465
uses: docker/login-action@v2
66+
# Only attempt login and push if we have credentials
67+
if: env.DOCKER_PUSH == 'true'
6568
with:
6669
username: ${{ secrets.DOCKERHUB_USERNAME }}
6770
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -78,4 +81,4 @@ jobs:
7881
STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }}
7982
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
8083
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
81-
push: true
84+
push: ${{ env.DOCKER_PUSH }}

.github/workflows/image-build-debian-binary.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
run: |
5050
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
5151
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
52+
echo "DOCKER_PUSH=${{ (secrets.DOCKERHUB_USERNAME != '') && (secrets.DOCKERHUB_PASSWORD != '') }}" >> $GITHUB_ENV
5253
- name: Set up QEMU
5354
id: docker_qemu
5455
uses: docker/setup-qemu-action@v2
@@ -73,6 +74,8 @@ jobs:
7374
- name: Login to DockerHub
7475
id: docker_login
7576
uses: docker/login-action@v2
77+
# Only attempt login and push if we have credentials
78+
if: env.DOCKER_PUSH == 'true'
7679
with:
7780
username: ${{ secrets.DOCKERHUB_USERNAME }}
7881
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -89,4 +92,4 @@ jobs:
8992
STACKS_NODE_VERSION=${{ inputs.tag || env.GITHUB_SHA_SHORT }}
9093
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
9194
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
92-
push: true
95+
push: ${{ env.DOCKER_PUSH }}

.github/workflows/image-build-debian-source.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
run: |
4747
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
4848
echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
49+
echo "DOCKER_PUSH=${{ (secrets.DOCKERHUB_USERNAME != '') && (secrets.DOCKERHUB_PASSWORD != '') }}" >> $GITHUB_ENV
4950
- name: Set up QEMU
5051
id: docker_qemu
5152
uses: docker/setup-qemu-action@v2
@@ -72,6 +73,8 @@ jobs:
7273
- name: Login to DockerHub
7374
id: docker_login
7475
uses: docker/login-action@v2
76+
# Only attempt login and push if we have credentials
77+
if: env.DOCKER_PUSH == 'true'
7578
with:
7679
username: ${{ secrets.DOCKERHUB_USERNAME }}
7780
password: ${{ secrets.DOCKERHUB_PASSWORD }}
@@ -87,4 +90,4 @@ jobs:
8790
STACKS_NODE_VERSION=${{ env.GITHUB_SHA_SHORT }}
8891
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
8992
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
90-
push: true
93+
push: ${{ env.DOCKER_PUSH }}

0 commit comments

Comments
 (0)