mirror of
https://github.com/docker/login-action.git
synced 2026-01-20 07:02:37 +08:00
Feature: Enable Multi Registry login Authentication
Signed-off-by: unknown <arunkumarthiyagarajan95@gmail.com>
This commit is contained in:
parent
ef38ec311a
commit
8d9860ef0e
6 changed files with 5287 additions and 8077 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import * as core from '@actions/core';
|
||||
|
||||
export interface Inputs {
|
||||
registry: string;
|
||||
registry: string[];
|
||||
username: string;
|
||||
password: string;
|
||||
ecr: string;
|
||||
|
|
@ -10,7 +10,7 @@ export interface Inputs {
|
|||
|
||||
export function getInputs(): Inputs {
|
||||
return {
|
||||
registry: core.getInput('registry'),
|
||||
registry: core.getMultilineInput('registry'),
|
||||
username: core.getInput('username'),
|
||||
password: core.getInput('password'),
|
||||
ecr: core.getInput('ecr'),
|
||||
|
|
|
|||
11
src/main.ts
11
src/main.ts
|
|
@ -4,18 +4,23 @@ import * as context from './context';
|
|||
import * as docker from './docker';
|
||||
import * as stateHelper from './state-helper';
|
||||
|
||||
const input: context.Inputs = context.getInputs();
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
const input: context.Inputs = context.getInputs();
|
||||
stateHelper.setRegistry(input.registry);
|
||||
stateHelper.setLogout(input.logout);
|
||||
await docker.login(input.registry, input.username, input.password, input.ecr);
|
||||
for (const reg of input.registry) {
|
||||
await docker.login(reg, input.username, input.password, input.ecr);
|
||||
}
|
||||
}
|
||||
|
||||
async function post(): Promise<void> {
|
||||
if (!stateHelper.logout) {
|
||||
return;
|
||||
}
|
||||
await docker.logout(stateHelper.registry);
|
||||
for (const reg of input.registry) {
|
||||
await docker.logout(reg);
|
||||
}
|
||||
}
|
||||
|
||||
actionsToolkit.run(main, post);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ import * as core from '@actions/core';
|
|||
export const registry = process.env['STATE_registry'] || '';
|
||||
export const logout = /true/i.test(process.env['STATE_logout'] || '');
|
||||
|
||||
export function setRegistry(registry: string) {
|
||||
core.saveState('registry', registry);
|
||||
export function setRegistry(registry: string[]) {
|
||||
core.info(`Setting registry: ${registry.join(',')}`);
|
||||
core.saveState('registry', registry.join(','));
|
||||
}
|
||||
|
||||
export function setLogout(logout: boolean) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue