Skip to content

Commit 7540fcc

Browse files
committed
fix: Skip Docker workflow when DOCKER_USERNAME is unset
Gate all Docker container build jobs on the DOCKER_USERNAME secret so forks and repos without Docker Hub credentials do not run scheduled, tag, or labeled PR builds.
1 parent 87218d4 commit 7540fcc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

.github/workflows/docker-containers.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
# Fork PR builds run only when a maintainer adds the "docker" label. Login and push
33
# are disabled for fork PRs; labeled fork PRs still execute untrusted Dockerfiles.
4+
# Skipped entirely when DOCKER_USERNAME is not configured (e.g. forks).
45
name: Docker Container Builds
56

67
on:
@@ -31,7 +32,7 @@ env:
3132
DOCKER_PUSH: true
3233
jobs:
3334
pwpush-container:
34-
if: (github.event.label && github.event.label.name == 'docker') || github.event_name != 'pull_request'
35+
if: secrets.DOCKER_USERNAME != '' && ((github.event.label && github.event.label.name == 'docker') || github.event_name != 'pull_request')
3536
runs-on: ubuntu-latest
3637
steps:
3738
- name: Checkout
@@ -91,7 +92,7 @@ jobs:
9192

9293

9394
public-gateway-container:
94-
if: (github.event.label && github.event.label.name == 'docker') || github.event_name != 'pull_request'
95+
if: secrets.DOCKER_USERNAME != '' && ((github.event.label && github.event.label.name == 'docker') || github.event_name != 'pull_request')
9596
needs: pwpush-container
9697
runs-on: ubuntu-latest
9798
steps:
@@ -156,7 +157,7 @@ jobs:
156157
template: job_failed
157158

158159
worker-container:
159-
if: (github.event.label && github.event.label.name == 'docker') || github.event_name != 'pull_request'
160+
if: secrets.DOCKER_USERNAME != '' && ((github.event.label && github.event.label.name == 'docker') || github.event_name != 'pull_request')
160161
needs: pwpush-container
161162
runs-on: ubuntu-latest
162163
steps:

0 commit comments

Comments
 (0)