Skip to content

Missing credentials when setting the context #662

@dud225

Description

@dud225

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 }}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions