mirror of
https://github.com/docker/login-action.git
synced 2025-11-05 19:56:22 +08:00
Compare commits
2 Commits
c6fa29c05d
...
6c096ac234
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c096ac234 | ||
|
|
eaed1d819a |
46
.github/workflows/ci.yml
vendored
46
.github/workflows/ci.yml
vendored
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -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')
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user