Skip to content

Commit dfd929c

Browse files
committed
Don't log in to container registries when credentials are unavailable
1 parent a54ed75 commit dfd929c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
DOCKER_HUB_USERNAME: shepmaster
1313
GH_CONTAINER_REGISTRY_USERNAME: shepmaster
1414
AWS_ACCESS_KEY_ID: AKIAWESVHZ3J6US4DSXP
15+
SECRETS_ARE_AVAILABLE: "${{ secrets.SECRETS_ARE_AVAILABLE }}"
1516
jobs:
1617
build_compiler_containers:
1718
name: Build ${{ matrix.channel }} compiler container
@@ -37,6 +38,7 @@ jobs:
3738
registry: ghcr.io
3839
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}"
3940
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}"
41+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
4042
- name: Build and push 'toolchain' container
4143
env:
4244
TAG_PREFIX: "${{ env.IMAGE_NAME }}:toolchain"
@@ -139,6 +141,7 @@ jobs:
139141
registry: ghcr.io
140142
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}"
141143
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}"
144+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
142145
- name: Build and push container
143146
uses: docker/build-push-action@v2
144147
with:
@@ -291,6 +294,7 @@ jobs:
291294
registry: ghcr.io
292295
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}"
293296
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}"
297+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
294298
- name: Login to Docker Hub
295299
uses: docker/login-action@v1
296300
with:

.github/workflows/cron.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
---
33
name: Scheduled rebuild
44
'on':
5-
workflow_dispatch:
5+
workflow_dispatch:
66
schedule:
77
- cron: 7 2 * * *
88
env:
99
DOCKER_HUB_USERNAME: shepmaster
1010
GH_CONTAINER_REGISTRY_USERNAME: shepmaster
1111
AWS_ACCESS_KEY_ID: AKIAWESVHZ3J6US4DSXP
12+
SECRETS_ARE_AVAILABLE: "${{ secrets.SECRETS_ARE_AVAILABLE }}"
1213
jobs:
1314
build_compiler_containers:
1415
name: Build ${{ matrix.channel }} compiler container
@@ -36,11 +37,13 @@ jobs:
3637
registry: ghcr.io
3738
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}"
3839
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}"
40+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
3941
- name: Login to Docker Hub
4042
uses: docker/login-action@v1
4143
with:
4244
username: "${{ env.DOCKER_HUB_USERNAME }}"
4345
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
46+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
4447
- name: Build and push 'toolchain' container
4548
env:
4649
TAG_PREFIX: "${{ env.IMAGE_NAME }}:toolchain"
@@ -155,11 +158,13 @@ jobs:
155158
registry: ghcr.io
156159
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}"
157160
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}"
161+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
158162
- name: Login to Docker Hub
159163
uses: docker/login-action@v1
160164
with:
161165
username: "${{ env.DOCKER_HUB_USERNAME }}"
162166
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
167+
if: "${{ env.SECRETS_ARE_AVAILABLE }}"
163168
- name: Build and push container
164169
uses: docker/build-push-action@v2
165170
with:

ci/workflows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ components:
44
DOCKER_HUB_USERNAME: shepmaster
55
GH_CONTAINER_REGISTRY_USERNAME: shepmaster
66
AWS_ACCESS_KEY_ID: AKIAWESVHZ3J6US4DSXP
7+
SECRETS_ARE_AVAILABLE: ${{ secrets.SECRETS_ARE_AVAILABLE }} # https://github.com/actions/runner/issues/520
78

89
- checkout: &checkout
910
name: "Checkout code"
@@ -23,13 +24,15 @@ components:
2324
registry: ghcr.io
2425
username: ${{ env.GH_CONTAINER_REGISTRY_USERNAME }}
2526
password: ${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}
27+
if: ${{ env.SECRETS_ARE_AVAILABLE }}
2628

2729
- login_docker_hub: &login_docker_hub
2830
name: "Login to Docker Hub"
2931
uses: docker/login-action@v1
3032
with:
3133
username: ${{ env.DOCKER_HUB_USERNAME }}
3234
password: ${{ secrets.DOCKER_HUB_TOKEN }}
35+
if: ${{ env.SECRETS_ARE_AVAILABLE }}
3336

3437
- build_compiler_containers_job: &build_compiler_containers_job
3538
name: "Build ${{ matrix.channel }} compiler container"

0 commit comments

Comments
 (0)