question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support logging to multiple registries with a single execution of the Action

See original GitHub issue

Currently, I need to login to three registries, which makes it very verbose to use this Action:

    - name: Login to ghcr.io
      uses: docker/login-action@v1
      with:
        registry: ghcr.io
        username: gha
        password: ${{ github.token }}
        
    - name: Login to docker.io
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        
    - name: Login to GCR
       uses: docker/login-action@v1
       with:
         registry: gcr.io
         username: _json_key
         password: ${{ secrets.GCR_JSON_KEY }}

It would be nice if providing a list of targets was supported. For instance:

    - name: Login to container registries
      uses: docker/login-action@v2
      with:
        targets:
          - 'ghcr.io|gha|${{ github.token }}'
          - 'docker.io|${{ secrets.DOCKER_USERNAME }}|${{ secrets.DOCKER_PASSWORD }}'
          - 'gcr.io|_json_key|${{ secrets.GCR_JSON_KEY }}'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
crazy-maxcommented, Jul 14, 2021

@tpolekhin Thanks for your feedback, that sounds like legitimate to me so yes I think we could improve the current behavior. About design I will think about it. I also saw the composite actions ADR recently that could be beneficial for this use case.

0reactions
umarcorcommented, Jul 18, 2021

I’m closing this issue since the proposed feature is not to be implemented here.

FTR, I’m using a single plain JavaScript file as an alternative:

    - name: Login to container registries
      if: github.event_name != 'pull_request' && github.repository == 'hdl/containers'
      uses: ./utils/registry-login
      with:
        cmd: |
          echo '${{ secrets.GCR_JSON_KEY }}' | docker login gcr.io -u _json_key --password-stdin
          echo '${{ github.token }}' | docker login ghcr.io -u gha --password-stdin
          echo '${{ secrets.DOCKER_PASS }}' | docker login docker.io -u '${{ secrets.DOCKER_USER }}' --password-stdin
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) {
      console.error(`exec error: ${error}`);
    }
    return error;
  });
}

// Are we in the 'post' step?
const registries = process.env.STATE_REGISTRIES;
if ( registries != undefined ) {
  for ( const item of registries.split(',') ) { run(`docker logout ${item.trim()}`); };
  return;
}

// Otherwise, this is the main step
run(process.env.INPUT_CMD);
console.log(`::save-state name=REGISTRIES::gcr.io,ghcr.io,docker.io`);

Ref: https://github.com/hdl/containers/tree/main/utils/registry-login

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way to configure multiple registries in a single ...
You can have multiple registries for scoped packages in your .npmrc file. For example: @polymer:registry=<url register A> registry=http://localhost:4873/.
Read more >
Python Logging Guide - Best Practices and Hands-on Examples
The rest of this guide is focused on how to log in Python using the built-in support for logging. It introduces various concepts...
Read more >
Apache Log4j "Log4Shell" Remote Code Execution 0-Day ...
The challenge with this vulnerability is widespread use of this particular logging utility in many enterprise and cloud applications. JDNI lookups support ......
Read more >
Windows registry information for advanced users
Describes the Windows registry and provides information about how to edit it.
Read more >
GitLab Container Registry administration
Ensure you choose a port different than the one that Registry listens to ( 5000 by default), ... Each time reconfigure is executed,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found