Skip to content

Commit 8be97b0

Browse files
committed
also allow passing-in auth-token for publishing ocm-component-descriptor
1 parent bb95411 commit 8be97b0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/workflows/post-build.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ on:
108108
type: boolean
109109
default: true
110110
description: see partner input for details
111+
secrets:
112+
oci-auth-token:
113+
required: false
114+
description: |
115+
An optional authtoken to use for authenticating against oci-push-target (used to publish
116+
OCM-Component-Descriptor). It is written
117+
unchanged into `$HOME/.docker/config.json`, and is assumed to be base64-encoded output of
118+
`<username>:<secret>`.
119+
120+
Note that it is only necessary to pass an auth-token if OIDC-authentication is not
121+
possible. OIDC-Authentication should be preferred over using a static token.
111122
outputs:
112123
component-descriptor:
113124
description: |
@@ -167,12 +178,25 @@ jobs:
167178
rm -rf prepare-values.d prepare-workflow-values.tar
168179
echo "can-push=${can_push}" >> ${GITHUB_OUTPUT}
169180
181+
- name: create-extra-auth
182+
id: extra-auth
183+
shell: bash
184+
run: |
185+
set -euo pipefail
186+
# we cannot check secrets on step-level
187+
if [ -z "${{ secrets.oci-auth-token }}" ]; then
188+
exit 0
189+
fi
190+
host=$(echo ${{ steps.read-oci-ref.outputs.ocm-target-oci-ref }} | cut -d/ -f1)
191+
echo "extra-auths={\"$host\": {\"auth\": \"${{ secrets.oci-auth-token }}\"}}" \
192+
>> $GITHUB_OUTPUT
170193
- name: authenticate-against-oci-registry
171194
if: ${{ steps.prep.outputs.can-push == 'true' }}
172195
uses: gardener/cc-utils/.github/actions/oci-auth@master
173196
with:
174197
oci-image-reference: ${{ steps.read-oci-ref.outputs.ocm-target-oci-ref }}
175198
gh-token: ${{ secrets.GITHUB_TOKEN }}
199+
extra-auths: ${{ steps.extra-auth.outputs.extra-auths }}
176200
- uses: gardener/cc-utils/.github/actions/ocm-validate@master
177201
with:
178202
component-descriptor-path: /tmp/ocm/component-descriptor.yaml

0 commit comments

Comments
 (0)