Skip to content

Commit 805ed8f

Browse files
committed
Attempt to make the OCI workflow behave reasonably for PRs
When repo secrets are not available to the actions run, the docker image is built, but not published
1 parent 65a3ac4 commit 805ed8f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/oci.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,17 @@ jobs:
103103
restore-keys: |
104104
${{ runner.os }}-${{ matrix.image_tag_suffix }}-buildx-
105105
106+
- name: Check for Push Credentials
107+
id: authorized
108+
run: |
109+
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ]; then
110+
echo "::set-output name=PUSH::true"
111+
else
112+
echo "::set-output name=PUSH::false"
113+
fi
114+
106115
- name: Login to DockerHub
116+
if: steps.authorized.outputs.PUSH
107117
uses: docker/login-action@v1
108118
with:
109119
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -124,7 +134,7 @@ jobs:
124134
uses: docker/build-push-action@v2
125135
with:
126136
context: packaging/docker-image
127-
push: true
137+
push: ${{ steps.authorized.outputs.PUSH }}
128138
tags: |
129139
pivotalrabbitmq/rabbitmq:${{ steps.compute-tags.outputs.TAG_1 }}
130140
pivotalrabbitmq/rabbitmq:${{ steps.compute-tags.outputs.TAG_2 }}

0 commit comments

Comments
 (0)