2 Commits

Author SHA1 Message Date
CrazyMax
6c096ac234 chore: update generated content
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-09-08 16:17:15 +02:00
CrazyMax
eaed1d819a multiple logins support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-09-08 16:16:05 +02:00
7 changed files with 56 additions and 11 deletions

View File

@@ -300,7 +300,7 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
add: |
logins: |
- username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- registry: public.ecr.aws
@@ -309,3 +309,47 @@ jobs:
- registry: registry.gitlab.com
username: ${{ secrets.GITLAB_USERNAME }}
password: ${{ secrets.GITLAB_TOKEN }}
multi-logins-only:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to registries
uses: ./
with:
logins: |
- username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- registry: registry.gitlab.com
username: ${{ secrets.GITLAB_USERNAME }}
password: ${{ secrets.GITLAB_TOKEN }}
multi-dup:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to registries
uses: ./
with:
logins: |
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -507,6 +507,7 @@ The following inputs can be used as `step.with` keys:
| `password` | String | | Password or personal access token for authenticating the Docker registry |
| `ecr` | String | `auto` | Specifies whether the given registry is ECR (`auto`, `true` or `false`) |
| `logout` | Bool | `true` | Log out from the Docker registry at the end of a job |
| `logins` | YAML | | Add other registries to authenticate to, defined as YAML objects |
## Contributing

View File

@@ -24,8 +24,8 @@ inputs:
description: 'Log out from the Docker registry at the end of a job'
default: 'true'
required: false
add:
description: 'Add other registries to authenticate to defined as YAML objects'
logins:
description: 'Add other registries to authenticate to, defined as YAML objects'
required: false
runs:

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@ export interface Inputs {
password: string;
ecr: string;
logout: boolean;
add: string;
logins: string;
}
export function getInputs(): Inputs {
@@ -16,6 +16,6 @@ export function getInputs(): Inputs {
password: core.getInput('password'),
ecr: core.getInput('ecr'),
logout: core.getBooleanInput('logout'),
add: core.getInput('add')
logins: core.getInput('logins')
};
}

View File

@@ -27,9 +27,9 @@ export async function main(): Promise<void> {
});
}
const add = yaml.load(inputs.add) as Auth[];
if (Array.isArray(add)) {
auths.push(...add);
const logins = yaml.load(inputs.logins) as Auth[];
if (Array.isArray(logins)) {
auths.push(...logins);
}
const registries: string[] = [];
@@ -40,7 +40,7 @@ export async function main(): Promise<void> {
registries.push(auth.registry);
}
}
stateHelper.setRegistries(registries);
stateHelper.setRegistries(registries.filter((value, index, self) => self.indexOf(value) === index));
if (auths.length == 0) {
throw new Error('No registry to login');