Skip to content

Commit b355ab7

Browse files
authored
GHA: only try to publish docker image if secrets are set (#2310)
1 parent 7a06016 commit b355ab7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.github/workflows/deploy_protected.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@ on:
1313
workflow_dispatch:
1414

1515
jobs:
16+
check-secret:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
secrets-defined: ${{ steps.secret-check.outputs.defined }}
20+
steps:
21+
- name: Check for Secret availability
22+
id: secret-check
23+
shell: bash
24+
run: |
25+
if [ "${{ secrets.DOCKER_USERNAME }}" != '' ]; then
26+
echo "defined=true" >> $GITHUB_OUTPUT;
27+
else
28+
echo "defined=false" >> $GITHUB_OUTPUT;
29+
fi
30+
1631
dockerhub:
1732
name: Deploy Dockerhub
18-
if: github.event.pull_request.head.repo.fork == false
33+
needs: [check-secret]
34+
if: needs.check-secret.outputs.secrets-defined == 'true'
1935
runs-on: ubuntu-22.04
2036

2137
strategy:

0 commit comments

Comments
 (0)