mirror of
https://github.com/docker/login-action.git
synced 2025-11-09 20:26: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
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
add: |
|
logins: |
|
||||||
- username: ${{ secrets.DOCKERHUB_USERNAME }}
|
- username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- registry: public.ecr.aws
|
- registry: public.ecr.aws
|
||||||
@@ -309,3 +309,47 @@ jobs:
|
|||||||
- registry: registry.gitlab.com
|
- registry: registry.gitlab.com
|
||||||
username: ${{ secrets.GITLAB_USERNAME }}
|
username: ${{ secrets.GITLAB_USERNAME }}
|
||||||
password: ${{ secrets.GITLAB_TOKEN }}
|
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 |
|
| `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`) |
|
| `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 |
|
| `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
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ inputs:
|
|||||||
description: 'Log out from the Docker registry at the end of a job'
|
description: 'Log out from the Docker registry at the end of a job'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
add:
|
logins:
|
||||||
description: 'Add other registries to authenticate to defined as YAML objects'
|
description: 'Add other registries to authenticate to, defined as YAML objects'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
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;
|
password: string;
|
||||||
ecr: string;
|
ecr: string;
|
||||||
logout: boolean;
|
logout: boolean;
|
||||||
add: string;
|
logins: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
@@ -16,6 +16,6 @@ export function getInputs(): Inputs {
|
|||||||
password: core.getInput('password'),
|
password: core.getInput('password'),
|
||||||
ecr: core.getInput('ecr'),
|
ecr: core.getInput('ecr'),
|
||||||
logout: core.getBooleanInput('logout'),
|
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[];
|
const logins = yaml.load(inputs.logins) as Auth[];
|
||||||
if (Array.isArray(add)) {
|
if (Array.isArray(logins)) {
|
||||||
auths.push(...add);
|
auths.push(...logins);
|
||||||
}
|
}
|
||||||
|
|
||||||
const registries: string[] = [];
|
const registries: string[] = [];
|
||||||
@@ -40,7 +40,7 @@ export async function main(): Promise<void> {
|
|||||||
registries.push(auth.registry);
|
registries.push(auth.registry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stateHelper.setRegistries(registries);
|
stateHelper.setRegistries(registries.filter((value, index, self) => self.indexOf(value) === index));
|
||||||
|
|
||||||
if (auths.length == 0) {
|
if (auths.length == 0) {
|
||||||
throw new Error('No registry to login');
|
throw new Error('No registry to login');
|
||||||
|
|||||||
Reference in New Issue
Block a user