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

Missing credentials when setting the context #662

Closed
dud225 opened this issue Aug 3, 2022 · 5 comments · Fixed by #663
Closed

Missing credentials when setting the context #662

dud225 opened this issue Aug 3, 2022 · 5 comments · Fixed by #663
Labels
kind/bug Something isn't working

Comments

@dud225
Copy link
Contributor

dud225 commented Aug 3, 2022

Behaviour

Steps to reproduce this issue

Put the Docker context in a subdirectory e.g. server and run the following configuration:

      - name: Build image
        uses: docker/build-push-action@v3
        with:
          load: true
          # Syntax: https://docs.docker.com/engine/reference/commandline/build/
          context: "{{defaultContext}}:server"
          tags: ${{ steps.metadata.outputs.tags }} 
          labels: ${{ steps.metadata.outputs.labels }}

Actual behaviour

Failure to get the username:

/usr/bin/docker buildx build --iidfile /tmp/docker-build-push-9SllsU/iidfile --label org.opencontainers.image.title=app --label org.opencontainers.image.description= --label org.opencontainers.image.url=<redacted> --label org.opencontainers.image.source=<redacted> --label org.opencontainers.image.version=pr-11 --label org.opencontainers.image.created=2022-08-03T07:38:40.750Z --label org.opencontainers.image.revision=2651e28ed8145bbd9f9cd8cb0dd6d7fc994b720a --label org.opencontainers.image.licenses= --label org.opencontainers.image.title=app --tag <redacted>:pr-11 --load --metadata-file /tmp/docker-build-push-9SllsU/metadata-file <redacted>.git#refs/pull/11/merge:server
#1 [internal] load git source <redacted>.git#refs/pull/11/merge:server
#0 0.113 hint: Using 'master' as the name for the initial branch. This default branch name
#0 0.113 hint: is subject to change. To configure the initial branch name to use in all
#0 0.113 hint: of your new repositories, which will suppress this warning, call:
#0 0.113 hint: 
#0 0.113 hint: 	git config --global init.defaultBranch <name>
#0 0.113 hint: 
#0 0.113 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
#0 0.113 hint: 'development'. The just-created branch can be renamed via this command:
#0 0.113 hint: 
#0 0.113 hint: 	git branch -m <name>
#1 0.119 Initialized empty Git repository in /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/1/fs/
#1 0.955 fatal: could not read Username for 'https://github.com/': terminal prompts disabled
#1 ERROR: failed to fetch remote <redacted>.git: exit status 128
------
 > [internal] load git source <redacted>.git#refs/pull/11/merge:server:
#0 0.113 hint: of your new repositories, which will suppress this warning, call:
#0 0.113 hint: 
#0 0.113 hint: 	git config --global init.defaultBranch <name>
#0 0.113 hint: 
#0 0.113 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
#0 0.113 hint: 'development'. The just-created branch can be renamed via this command:
#0 0.113 hint: 
#0 0.113 hint: 	git branch -m <name>
#1 0.119 Initialized empty Git repository in /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/1/fs/
#1 0.955 fatal: could not read Username for 'https://github.com/': terminal prompts disabled

Setting explicitely the Github token allows to work around the issue:

        with:
          [...]
          secrets: "GIT_AUTH_TOKEN=${{ github.token }}"
@crazy-max
Copy link
Member

Good catch. Atm we don't set automatically the GIT_AUTH_TOKEN if context is not equal to {{defaultContext}}. We should exclude subdir in this cond so it would match and automatically inject the token. Will fix that.

@crazy-max
Copy link
Member

crazy-max commented Aug 3, 2022

@dud225 Can you test with:

uses: crazy-max/docker-build-push-action@fix-git-token-cond

And let me know? Thanks

@dud225
Copy link
Contributor Author

dud225 commented Aug 3, 2022

Unfortunately it doesn't work, still the same error
github_actions.log.gz

@crazy-max
Copy link
Member

@djs55 I forgot to take into account the template case. Should be fine now, let me know.

@dud225
Copy link
Contributor Author

dud225 commented Aug 3, 2022

@crazy-max I confirm that it works fine
thanks for the quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants