3535 gcp-wif-project-id :
3636 description : " GCP project ID"
3737 value : ${{ jobs.setup-registry-identities.outputs.gcp-wif-project-id }}
38+ dockerhub-oidc-enabled :
39+ description : " Whether a Docker Hub OIDC registry identity was configured"
40+ value : ${{ jobs.setup-registry-identities.outputs.dockerhub-oidc-enabled }}
41+ dockerhub-oidc-registry :
42+ description : " Docker Hub registry hostname"
43+ value : ${{ jobs.setup-registry-identities.outputs.dockerhub-oidc-registry }}
44+ dockerhub-oidc-username :
45+ description : " Docker Hub username or organization to authenticate as"
46+ value : ${{ jobs.setup-registry-identities.outputs.dockerhub-oidc-username }}
47+ dockerhub-oidc-connection-id :
48+ description : " Docker Hub OIDC connection ID"
49+ value : ${{ jobs.setup-registry-identities.outputs.dockerhub-oidc-connection-id }}
3850
3951env :
4052 RUNTIME_MODULE : " @docker/github-builder-runtime@0.94.0"
6274 gcp-wif-workload-identity-provider : ${{ steps.validate.outputs.gcp-wif-workload-identity-provider }}
6375 gcp-wif-service-account : ${{ steps.validate.outputs.gcp-wif-service-account }}
6476 gcp-wif-project-id : ${{ steps.validate.outputs.gcp-wif-project-id }}
77+ dockerhub-oidc-enabled : ${{ steps.validate.outputs.dockerhub-oidc-enabled }}
78+ dockerhub-oidc-registry : ${{ steps.validate.outputs.dockerhub-oidc-registry }}
79+ dockerhub-oidc-username : ${{ steps.validate.outputs.dockerhub-oidc-username }}
80+ dockerhub-oidc-connection-id : ${{ steps.validate.outputs.dockerhub-oidc-connection-id }}
6581 steps :
6682 -
6783 name : Install dependencies
@@ -111,6 +127,10 @@ jobs:
111127 core.setOutput('gcp-wif-workload-identity-provider', '');
112128 core.setOutput('gcp-wif-service-account', '');
113129 core.setOutput('gcp-wif-project-id', '');
130+ core.setOutput('dockerhub-oidc-enabled', 'false');
131+ core.setOutput('dockerhub-oidc-registry', '');
132+ core.setOutput('dockerhub-oidc-username', '');
133+ core.setOutput('dockerhub-oidc-connection-id', '');
114134 };
115135
116136 const registryIdentities = core.getInput('registry-identities', {trimWhitespace: false});
@@ -142,6 +162,12 @@ jobs:
142162 }
143163 return value.trim();
144164 };
165+ const optionalString = (entry, key, path, defaultValue) => {
166+ if (!Object.prototype.hasOwnProperty.call(entry, key)) {
167+ return defaultValue;
168+ }
169+ return requireString(entry, key, path);
170+ };
145171 let parsed;
146172 try {
147173 parsed = yaml.load(registryIdentities);
@@ -161,6 +187,7 @@ jobs:
161187
162188 let awsEcr;
163189 let gcpWif;
190+ let dockerhubOidc;
164191 entries.forEach((entry, index) => {
165192 const path = `registry-identities[${index}]`;
166193 ensureObject(entry, path);
@@ -201,6 +228,23 @@ jobs:
201228 };
202229 break;
203230 }
231+ case 'dockerhub': {
232+ const allowedKeys = new Set(['type', 'registry', 'username', 'connection_id']);
233+ for (const key of Object.keys(entry)) {
234+ if (!allowedKeys.has(key)) {
235+ fail(`${path}.${key} is not supported for dockerhub`);
236+ }
237+ }
238+ if (dockerhubOidc) {
239+ fail('only one dockerhub registry identity is supported');
240+ }
241+ dockerhubOidc = {
242+ registry: optionalString(entry, 'registry', path, 'docker.io'),
243+ username: requireString(entry, 'username', path),
244+ connectionID: requireString(entry, 'connection_id', path)
245+ };
246+ break;
247+ }
204248 default:
205249 fail(`${path}.type has unsupported provider ${type}`);
206250 }
@@ -215,3 +259,7 @@ jobs:
215259 core.setOutput('gcp-wif-workload-identity-provider', gcpWif?.workloadIdentityProvider || '');
216260 core.setOutput('gcp-wif-service-account', gcpWif?.serviceAccount || '');
217261 core.setOutput('gcp-wif-project-id', gcpWif?.projectId || '');
262+ core.setOutput('dockerhub-oidc-enabled', dockerhubOidc ? 'true' : 'false');
263+ core.setOutput('dockerhub-oidc-registry', dockerhubOidc?.registry || '');
264+ core.setOutput('dockerhub-oidc-username', dockerhubOidc?.username || '');
265+ core.setOutput('dockerhub-oidc-connection-id', dockerhubOidc?.connectionID || '');
0 commit comments