add registry-login input for optional registry auth before build#117
add registry-login input for optional registry auth before build#117
Conversation
97e2afd to
e36e467
Compare
tonistiigi
left a comment
There was a problem hiding this comment.
I'm not sure why this isn't the default.
If this is to prevent early login for public pull then that could be handled with the scope property.
If this is needed, then why isn't it in registry auth config, per-registry?
Good point. I tested this and registry-login: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}This is similar to what we do in our repos like https://github.com/moby/buildkit-bench/blob/0ba0908a5f906bc469d6ebdca9731942432c81c9/.github/workflows/ci.yml#L81 but here we gate the login-action. Alternatively we would have a new secrets:
registry-auths: |
- registry: docker.io
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
skip: ${{ github.event_name = 'pull_request' }}Or secrets:
registry-auths: |
- registry: docker.io
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
enable: ${{ github.event_name != 'pull_request' }}WDYT? |
Or just skip automatically if "password" (or any other credential method) is empty? |
If we have OIDC in play in the future, |
Opened docker/login-action#925 |
|
Ok after thinking more about it, I think this should stay explicit in github-builder. The need to skip login on fork PRs is workflow/event policy, not really registry auth schema. |
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
e36e467 to
3391599
Compare
This PR adds a
registry-logininput to both reusable workflows to control whether registry login happens before the build step. The input supportsauto,true, andfalse:autopreserves the current behavior and enables login only whenoutput=imageandpush=truetruealways attempts a pre-build loginfalsedisables pre-build loginThis makes pre-build registry authentication available for cases such as local output or non-push builds, while keeping the default behavior unchanged.