Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support List,CSV type for registry input #87

Open
tpolekhin opened this issue Jul 19, 2021 · 4 comments
Open

Support List,CSV type for registry input #87

tpolekhin opened this issue Jul 19, 2021 · 4 comments

Comments

@tpolekhin
Copy link

tpolekhin commented Jul 19, 2021

Opening new issue to keep track of the implementation because original issue was closed #72

Right now we're using this action to login to IBM Cloud Container Registry in different regions:

      - name: Login to IBM Cloud Container Registry US
        uses: docker/login-action@v1
        with:
          registry: us.icr.io
          username: ${{ env.ICR_USERNAME }}
          password: ${{ env.ICR_PASSWORD }}

      - name: Login to IBM Cloud Container Registry UK
        uses: docker/login-action@v1
        with:
          registry: uk.icr.io
          username: ${{ env.ICR_USERNAME }}
          password: ${{ env.ICR_PASSWORD }}

Credentials are the same for all regions, it's just the address of the registry that differs.

Could we possibly support something like this?

      - name: Login to IBM Cloud Container Registry ALL
        uses: docker/login-action@v1
        with:
          registry: |
            us.icr.io
            uk.icr.io
            de.icr.io
            au.icr.io
            jp.icr.io
          username: ${{ env.ICR_USERNAME }}
          password: ${{ env.ICR_PASSWORD }}
@umarcor
Copy link

umarcor commented Nov 21, 2021

FWIW:

env:
  ICR_DOMAINS: us uk de au jp

...

    uses: ./with-post-step
    with:
      main: |
        for domain in ${{ env.ICR_DOMAINS}}; do
          echo '${{ env.ICR_PASSWORD }}' | docker login "$domain".icr.io -u '${{ env.ICR_USERNAME }}' --password-stdin
        done
      post: for domain in ${{ env.ICR_DOMAINS}}; do docker logout "$domain"; done

where with-post-step/action.yml:

name: With post step
description: 'Generic JS Action to execute a main command and set a command in a post step.'
inputs:
  main:
    description: 'Main command/script.'
    required: true
  post:
    description: 'Post command/script.'
    required: true
  key:
    description: 'Name of the state variable used to detect the post step.'
    required: false
    default: POST
runs:
  using: 'node12'
  main: 'main.js'
  post: 'main.js'

and with-post-step/main.js:

const { exec } = require('child_process');

function run(cmd) {
  exec(cmd, (error, stdout, stderr) => {
    if ( stdout.length != 0 ) { console.log(`${stdout}`); }
    if ( stderr.length != 0 ) { console.error(`${stderr}`); }
    if (error) {
      process.exitCode = error.code;
      console.error(`${error}`);
    }
  });
}

const key = process.env.INPUT_KEY.toUpperCase();

if ( process.env[`STATE_${key}`] != undefined ) { // Are we in the 'post' step?
  run(process.env.INPUT_POST);
} else { // Otherwise, this is the main step
  console.log(`::save-state name=${key}::true`);
  run(process.env.INPUT_MAIN);
}

@iamludal
Copy link

iamludal commented Mar 8, 2023

Up, would also like this feature. Have to login to multiple registries with the same credentials.

@umarcor
Copy link

umarcor commented Mar 8, 2023

@Abdullah-Shahen
Copy link

Abdullah-Shahen commented May 20, 2024

@tpolekhin @iamludal @antonioua, @kscharm, @fmeriaux, @Flydiverny, @kpocius, @patrickbeekman I just released this feature here: Multi Registry Authenticator (MRA)

I'd love to have your opinion on it and if there's something missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants