Skip to content

Commit 5e287e9

Browse files
committed
allow explictly passing-in dockerhub-authtoken
If oci-ocm-workflow is called w/ explicitly-passed authtoken, it can no longer access other secrets (as is done for dockerhub-auth-token). Hence, allow it to a passed-in explicitly. Keep previous behaviour for convenience and backwards-compatibility.
1 parent 1c85e8d commit 5e287e9

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/oci-ocm.yaml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ on:
190190
191191
Note that it is only necessary to pass an auth-token if OIDC-authentication is not
192192
possible. OIDC-Authentication should be preferred over using a static token.
193+
dockerhub-auth-token:
194+
required: false
195+
description: |
196+
An optional authtoken that is harcdcoded to be used for authentication against dockerhub.
197+
This is often needed in order to avoid running into rate-limits.
198+
199+
For convenience, if this workflows is called inheriting all secrets, this is read from
200+
hardcoded secret `DOCKERHUB_RO_AUTH`. If passing secrets explicitly, and auth against
201+
dockerhub is required, this input must be provided.
202+
203+
It is passed as-as, and should be the result of base64-encoding `user:secret`
193204
194205
outputs:
195206
ocm-resource:
@@ -345,20 +356,26 @@ jobs:
345356
run: |
346357
set -euo pipefail
347358
# cannot check in if-clause above, as `secrets` ctx is not accessible there
348-
if [ -n '${{ secrets.DOCKERHUB_RO_AUTH }}' ]; then
359+
if [ -n '${{ secrets.dockerhub-auth-token }}' ]; then
360+
dockerhub_token='${{ secrets.dockerhub-auth-token }}'
361+
elif [ -n '${{ secrets.DOCKERHUB_RO_AUTH }}' ]; then
362+
dockerhub_token='${{ secrets.DOCKERHUB_RO_AUTH }}'
363+
fi
364+
365+
if [ -n '${dockerhub_token:-}' ]; then
349366
cat <<EOF >> /tmp/config.json
350367
{
351368
"registry-1.docker.io": {
352-
"auth": "${{ secrets.DOCKERHUB_RO_AUTH }}"
369+
"auth": "${dockerhub_token}"
353370
},
354371
"docker.io": {
355-
"auth": "${{ secrets.DOCKERHUB_RO_AUTH }}"
372+
"auth": "${dockerhub_token}"
356373
},
357374
"index.docker.io": {
358-
"auth": "${{ secrets.DOCKERHUB_RO_AUTH }}"
375+
"auth": "${dockerhub_token}"
359376
},
360377
"https://index.docker.io/v1/": {
361-
"auth": "${{ secrets.DOCKERHUB_RO_AUTH }}"
378+
"auth": "${dockerhub_token}"
362379
}
363380
}
364381
EOF

0 commit comments

Comments
 (0)