18
FROM golang:1.17-alpine as builder
ENV GOPRIVATE=github.com/XXXXX/
ARG GITHUB_TOKEN=$GITHUB_TOKEN
RUN apk update && apk add git gcc g++ libc-dev librdkafka-dev pkgconf && mkdir /app && git config --global url."https://someusername:$GITHUB_TOKEN@github.com".insteadOf "https://github.com"
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY ./ /app
RUN go build -tags dynamic


FROM alpine:3.1
RUN addgroup -S app && \
    apk add --no-cache librdkafka-dev
RUN mkdir /logs && mkdir /app
WORKDIR /app
USER app
EXPOSE 8000 8001 8002
CMD ["./main"]

fatal: could not read Username for 'https://github.com': terminal prompts disabled Confirm the import path was entered correctly. If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

Any idea how can I fix it inside docker

karel
  • 5,489
  • 46
  • 45
  • 50
EagerLearner
  • 447
  • 1
  • 5
  • 11

4 Answers4

28

When you're in an organization that uses SAML SSO, every personal access token that's used to access that organization's resources has to be specifically enabled for that organization.

You can go into the Personal Access Token settings and choose "Configure SSO". From there, you can enable the token for the specific organization that you're using. After that point, using it as normal should work.

bk2204
  • 64,793
  • 6
  • 84
  • 100
8

Double check if you have an SSH key associated with your account (https://github.com/settings/keys) and make sure it has SSO enabled as well.

Clemens
  • 653
  • 6
  • 8
  • As I see we need to associate each of our tokens with the organisation. I associated both, "Personal Access Token settings and choose "Configure SSO" and "SSH key" with my organisation and that helped to me. – Vladimir Mar 15 '23 at 12:30
1

I tried the suggestions for this to no avail.

The only way I could overcome this was by downloading the GitHub CLI and running:

gh auth login

This resolved the warning about SSO and OAuth.

Fenton
  • 241,084
  • 71
  • 387
  • 401
0

As answered above, make sure you go to personal access settings and ensure that configure sso for your token includes your ORGANIZATION-NAME. Additionally, I had to do an extra step for it work. I went to https://github.com/orgs/ORGANIZATION-NAME/sso

Source: https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/about-authentication-with-saml-single-sign-on