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

2FA and Github: how to solve could not read Username for 'https://github.com' #49

Open
rdehuyss opened this issue May 26, 2021 · 3 comments

Comments

@rdehuyss
Copy link

This is a follow-up for issue #43 . I just tried with a new release - still have some issues.

You can find drone.yml here: https://github.com/jobrunr/jobrunr/blob/master/.drone.yml.

What I try to do: update the Readme with the latest version (so the tag)
How do I try it:

  - name: update readme
    image: jobrunr.io/build-container:1.0
    commands:
      - rm -f *.hprof
      - sed -i "s@<version>.*</version>@<version>${DRONE_TAG}</version>@g" README.md # replace version in README
      - sed -i "s@'org.jobrunr:jobrunr:.*'@'org.jobrunr:jobrunr:${DRONE_TAG}'@g" README.md # replace version in README
      - git config --global --add url."git@github.com:".insteadOf "https://github.com/" # Switch to ssh instead of https

  - name: push updated readme
    image: appleboy/drone-git-push
    settings:
      branch: master
      remote_name: origin
      ssh_key:
        from_secret: GITHUB_SSH_KEY
      force: false
      commit: true
      commit_message: "Update readme to new version [CI SKIP]"
      author_name: drone-bot
      author_email: drone-bot@jobrunr.io

The output for step push updated readme:

latest: Pulling from appleboy/drone-git-push
--
2 | Digest: sha256:144fd3130840d8ca0eba4b2aa98da027086d2d3fee6f2fbf4914564ad0a3b3f1
3 | Status: Image is up to date for appleboy/drone-git-push:latest
4 | + git add --all
5 | + git diff-index --quiet HEAD --ignore-submodules
6 | + git commit -m Update readme to new version [CI SKIP]
7 | + git push origin HEAD:master
8 | fatal: could not read Username for 'https://github.com': terminal prompts disabled
9 | exit status 128

Any idea on how to solve this?

Thanks again,
Ronald

@pacbard
Copy link
Contributor

pacbard commented Jun 7, 2021

As a workaround, you can manually set the remote parameter with your username and access token: https://<gh_username>:<gh_access_token>@github.com:repo.

Altogether, it's something like this with the code you provided:

  - name: push updated readme
    image: appleboy/drone-git-push
    settings:
      branch: master
      remote:
         from_secret: GH_REPO
      force: false
      commit: true
      commit_message: "Update readme to new version [CI SKIP]"
      author_name: drone-bot
      author_email: drone-bot@jobrunr.io

Alternatively, if you want to use the ssh key instead of the access token, you will still have to set the remote address by hand. Something like this works for me:

  - name: push updated readme
    image: appleboy/drone-git-push
    settings:
      branch: master
      remote_name: origin
      remote: git@github.com:<repo>
      ssh_key:
        from_secret: GITHUB_SSH_KEY
      force: false
      commit: true
      commit_message: "Update readme to new version [CI SKIP]"
      author_name: drone-bot
      author_email: drone-bot@jobrunr.io

@rdehuyss
Copy link
Author

rdehuyss commented Jun 7, 2021

Thanks, I'll try it and report back.

fmoc pushed a commit to owncloud/client that referenced this issue Jun 7, 2021
TheOneRing pushed a commit to owncloud/client that referenced this issue Jun 7, 2021
@sevaho
Copy link

sevaho commented Aug 9, 2022

Hi

I am having the same issue, if I add an origin in the settings I get the following error:

+ git add --all
+ git diff-index --quiet HEAD --ignore-submodules
+ git remote add origin git@github.com:<repo>
error: remote origin already exists.
exit status 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants