@@ -15,27 +15,28 @@ inputs:
1515 description : |
1616 OCI registry configuration used to pull, push and cache images.
1717 Accepts either a registry hostname string (legacy format) or a JSON object.
18- JSON example: `{"pull":"docker.io","pull:private":"ghcr.io","push":"ghcr.io","cache":"ghcr.io" }`
18+ JSON example: `{"pull":"docker.io","pull:private":"ghcr.io","push":"ghcr.io"}`
1919 JSON object keys:
2020 - `pull`: registry used to pull public or default base images
2121 - `pull:<name>`: additional pull registry
2222 - `push`: registry used for published images
2323 - `cache`: registry used when `cache-type` is `registry`
24+ If no `pull` key is provided, the `push` registry is also used for pulls.
2425 default : " ghcr.io"
2526 required : true
2627 oci-registry-username :
2728 description : |
2829 Username configuration used to log against OCI registries.
2930 Accepts either a single username string (legacy format) or a JSON object using the same keys as `oci-registry`.
30- JSON example: `{"pull:private":"${{ github.repository_owner }}","push":"${{ github.repository_owner }}","cache":"${{ github.repository_owner }}" }`
31+ JSON example: `{"pull:private":"${{ github.repository_owner }}","push":"${{ github.repository_owner }}"}`
3132 See https://github.com/docker/login-action#usage.
3233 default : ${{ github.repository_owner }}
3334 required : true
3435 oci-registry-password :
3536 description : |
3637 Password or personal access token configuration used to log against OCI registries.
3738 Accepts either a single password/token string (legacy format) or a JSON object using the same keys as `oci-registry`.
38- JSON example: `{"pull:private":"${{ github.token }}","push":"${{ github.token }}","cache":"${{ github.token }}" }`
39+ JSON example: `{"pull:private":"${{ github.token }}","push":"${{ github.token }}"}`
3940 Can be passed in using `secrets.GITHUB_TOKEN`.
4041 See https://github.com/docker/login-action#usage.
4142 default : ${{ github.token }}
@@ -211,7 +212,7 @@ runs:
211212 }, {});
212213 }
213214
214- function resolveCredential (credentialMap, role, registry, pushRegistry) {
215+ function resolveCredentialByRole (credentialMap, role, registry, pushRegistry) {
215216 const legacyCredential = credentialMap.legacy ?? '';
216217
217218 if (role === 'push') {
@@ -286,8 +287,8 @@ runs:
286287 const registryLoginsByRegistry = new Map();
287288 for (const registryEntry of registryEntries) {
288289 const { role, registry, required } = registryEntry;
289- const username = resolveCredential (usernameByRole, role, registry, pushRegistry);
290- const password = resolveCredential (passwordByRole, role, registry, pushRegistry);
290+ const username = resolveCredentialByRole (usernameByRole, role, registry, pushRegistry);
291+ const password = resolveCredentialByRole (passwordByRole, role, registry, pushRegistry);
291292
292293 if ((username && !password) || (!username && password)) {
293294 throw new Error(`Credentials for "${role}" must define both username and password`);
@@ -301,8 +302,13 @@ runs:
301302 throw new Error(`Conflicting credentials configured for registry "${registry}"`);
302303 }
303304
304- existingRegistryLogin.username ||= username;
305- existingRegistryLogin.password ||= password;
305+ if (!existingRegistryLogin.username && username) {
306+ existingRegistryLogin.username = username;
307+ }
308+
309+ if (!existingRegistryLogin.password && password) {
310+ existingRegistryLogin.password = password;
311+ }
306312 existingRegistryLogin.required ||= required;
307313 continue;
308314 }
0 commit comments