11---
2+ # Fork PR builds run only when a maintainer adds the "docker" label. Login and push
3+ # are disabled for fork PRs; labeled fork PRs still execute untrusted Dockerfiles.
4+ # Skipped entirely when DOCKER_USERNAME is not configured (e.g. forks).
25name : Docker Container Builds
36
47on :
2225 types :
2326 - labeled
2427
28+ permissions :
29+ contents : read
30+
2531env :
2632 DOCKER_PUSH : true
2733jobs :
2834 pwpush-container :
29- 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')
3036 runs-on : ubuntu-latest
3137 steps :
3238 - name : Checkout
33- uses : actions/checkout@v6
39+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
3440 with :
3541 repository : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
3642 ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
3743 fetch-depth : 1
3844
3945 - name : Set up Docker Buildx
40- uses : docker/setup-buildx-action@v4
46+ uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
4147
4248 - name : Populate Docker metadata
4349 id : meta
44- uses : docker/metadata-action@v6
50+ uses : docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
4551 with :
4652 images : ${{ secrets.DOCKER_USERNAME }}/pwpush
4753 tags : |
@@ -55,13 +61,13 @@ jobs:
5561
5662 - name : Login to DockerHub
5763 if : github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork
58- uses : docker/login-action@v4
64+ uses : docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
5965 with :
6066 username : ${{ secrets.DOCKER_USERNAME }}
6167 password : ${{ secrets.DOCKER_PASSWORD }}
6268
6369 - name : Build and push Docker image
64- uses : docker/build-push-action@v7
70+ uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
6571 with :
6672 context : .
6773 file : ./containers/docker/Dockerfile
@@ -79,35 +85,35 @@ jobs:
7985 - name : Post job failure details to Campfire
8086 if : failure() && github.ref == 'refs/heads/master'
8187 continue-on-error : true
82- uses : shane-lamb/campfire-notify-action@v1.1.6
88+ uses : shane-lamb/campfire-notify-action@df63cf73810147306276e281bedccf71c1519caf # v1.1.6
8389 with :
8490 messages_url : ${{ secrets.CAMPFIRE_MESSAGES_URL }}
8591 template : job_failed
8692
8793
8894 public-gateway-container :
89- 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')
9096 needs : pwpush-container
9197 runs-on : ubuntu-latest
9298 steps :
9399 - name : Checkout
94- uses : actions/checkout@v6
100+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
95101 with :
96102 repository : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
97103 ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
98104 fetch-depth : 1
99105
100106 - name : Set up QEMU
101- uses : docker/setup-qemu-action@v4
107+ uses : docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4
102108 with :
103109 image : tonistiigi/binfmt:master
104110
105111 - name : Set up Docker Buildx
106- uses : docker/setup-buildx-action@v4
112+ uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
107113
108114 - name : Populate Docker metadata
109115 id : meta
110- uses : docker/metadata-action@v6
116+ uses : docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
111117 with :
112118 images : ${{ secrets.DOCKER_USERNAME }}/pwpush-public-gateway
113119 tags : |
@@ -121,13 +127,13 @@ jobs:
121127
122128 - name : Login to DockerHub
123129 if : github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork
124- uses : docker/login-action@v4
130+ uses : docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
125131 with :
126132 username : ${{ secrets.DOCKER_USERNAME }}
127133 password : ${{ secrets.DOCKER_PASSWORD }}
128134
129135 - name : Build and push Docker image
130- uses : docker/build-push-action@v7
136+ uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
131137 with :
132138 context : .
133139 file : ./containers/docker/Dockerfile.public-gateway
@@ -145,34 +151,34 @@ jobs:
145151 - name : Post job failure details to Campfire
146152 if : failure() && github.ref == 'refs/heads/master'
147153 continue-on-error : true
148- uses : shane-lamb/campfire-notify-action@v1.1.6
154+ uses : shane-lamb/campfire-notify-action@df63cf73810147306276e281bedccf71c1519caf # v1.1.6
149155 with :
150156 messages_url : ${{ secrets.CAMPFIRE_MESSAGES_URL }}
151157 template : job_failed
152158
153159 worker-container :
154- 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')
155161 needs : pwpush-container
156162 runs-on : ubuntu-latest
157163 steps :
158164 - name : Checkout
159- uses : actions/checkout@v6
165+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
160166 with :
161167 repository : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
162168 ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
163169 fetch-depth : 1
164170
165171 - name : Set up QEMU
166- uses : docker/setup-qemu-action@v4
172+ uses : docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4
167173 with :
168174 image : tonistiigi/binfmt:master
169175
170176 - name : Set up Docker Buildx
171- uses : docker/setup-buildx-action@v4
177+ uses : docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
172178
173179 - name : Populate Docker metadata
174180 id : meta
175- uses : docker/metadata-action@v6
181+ uses : docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6
176182 with :
177183 images : ${{ secrets.DOCKER_USERNAME }}/pwpush-worker
178184 tags : |
@@ -186,13 +192,13 @@ jobs:
186192
187193 - name : Login to DockerHub
188194 if : github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork
189- uses : docker/login-action@v4
195+ uses : docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
190196 with :
191197 username : ${{ secrets.DOCKER_USERNAME }}
192198 password : ${{ secrets.DOCKER_PASSWORD }}
193199
194200 - name : Build and push Docker image
195- uses : docker/build-push-action@v7
201+ uses : docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
196202 with :
197203 context : .
198204 file : ./containers/docker/Dockerfile.worker
@@ -210,7 +216,7 @@ jobs:
210216 - name : Post job failure details to Campfire
211217 if : failure() && github.ref == 'refs/heads/master'
212218 continue-on-error : true
213- uses : shane-lamb/campfire-notify-action@v1.1.6
219+ uses : shane-lamb/campfire-notify-action@df63cf73810147306276e281bedccf71c1519caf # v1.1.6
214220 with :
215221 messages_url : ${{ secrets.CAMPFIRE_MESSAGES_URL }}
216222 template : job_failed
0 commit comments