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

fatal: could not read Username for 'https://github.com': No such device or address #6

Open
paw-lu opened this issue Oct 21, 2022 · 6 comments

Comments

@paw-lu
Copy link

paw-lu commented Oct 21, 2022

Trying to use this action to authenticate git so it can push to main on a remote branch:

      - name: Setup git
        uses: oleksiyrudenko/[email protected]
        with:
          token: ${{ secrets.GH_TOKEN }}
          global: true
          name: Tester testy
          email: [email protected]
          actor: paw-lu

      - name: Commit
        working-directory: ./Dash-User-Contributions
        run: |
          git add --all
          git commit --message="Change!"

      - name: Push
        working-directory: ./Dash-User-Contributions
        run: |
          git push --set-upstream origin ${{ github.run_id }}-${{ github.run_attempt }}

But on step Push I get fatal: could not read Username for 'https://github.com': No such device or address

Example repo has been set up to provide a minimal example.


Thanks for the action!

@OleksiyRudenko
Copy link
Owner

OleksiyRudenko commented Nov 1, 2022

Hi @paw-lu,
Thank you for pinging me and apologies for not reverting to you any time sooner.
Looking into this.

Normally, this class of errors happens when authorization fails on remote operations.
I, apparently, cannot see your profile and your repo security settings.

Hence a question:

Is secrets.GH_TOKEN a PAT generated on your profile and associated with your GitHub username?

(1) If no, then probably you wanted to use secrets.GITHUB_TOKEN instead, which is provided to actions by default. Then actor would be GITHUB_ACTOR, also set on the runner environment. This action's actor parameter defaults to GITHUB_ACTOR, hence no need to specify it explicitly.

(I may be wrong as I've seen somewhere GH_TOKEN referred to on multiple docs outside github actions official documentation. Might be an alias).

(2) If yes, then you may want to check your PAT permissions and expiration date.

Feel free to reflecting on the above.

I will fork your test repo and run a couple of experiments to test hypotheses I have.

@paw-lu
Copy link
Author

paw-lu commented Nov 1, 2022

Absolutely nothing to be sorry about!

Is secrets.GH_TOKEN a PAT generated on your profile and associated with your GitHub username?

Yes. It's not an alias though, it was a token I generated.

Why use it instead of GITHUB_TOKEN? Apparently the generated token has more permissions than the defautl GITHUB_TOKEN. And there were some actions that I wanted to take that needed it.

(2) If yes, then you may want to check your PAT permissions and expiration date.

Checked!

  1. I tried with all permission enabled on a freshly generated token

  2. Am able to successfully get what I want done if I use the token manually (without the action). For example, for the push action I can successfully run:

% git push https://${{ secrets.GH_TOKEN }}@github.com/user/repo.git

Actually the only way I could figure out to use the token for authentication for push actions was to modify origin to explicitly include the token in the url.

I will fork your test repo and run a couple of experiments to test hypotheses I have.

Yeah go for it! Just be aware that the repo has changed quite a bit since then, and I linked to a specific hash: 75de3623b91773c2dc0a3da091913b1fc695edbb

@OleksiyRudenko
Copy link
Owner

@paw-lu looks like I am failing at resolving this. This is above my qualifications and knowledge of git and github fundamentals.

What I did: I set, iteratively, git credentials explicitly (using custom secrets.GH_TOKEN) via (a) env variables (GIT_* and GITHUB_ACTOR) and (b) git credentials helper (git credentials store; I thought that git might have been looking up for a user associated with https://github.com and expected to find it somewhere in a persistent credentials store). I had that custom token also listed among secrets on the fork that is being created by the workflow.

No combination worked.

Interestingly, as soon as I am trying to push changes to the main repo (i.e. the one that hosts the workflow) it goes smoothly.

I am run out of the ideas. I could use some help here.

In case you have any interest in what's been done code-wise:

  1. issues-with-token branch that corresponds to 75de3623b91773c2dc0a3da091913b1fc695edbb
  2. test-gha-221106 branch -- multiple commits in attempt to debug/pin-point the problem and solve it. Multiple failed attemps (ignore 2 latest runs; they come from the item 3 below).
  3. test-gha-221106-no-fork branch -- push changes to the repo that hosts the workflow. Works fine.
  4. earlier test-gha-221101 branch, essentially same conclusions as under item 3 above.

@paw-lu
Copy link
Author

paw-lu commented Nov 10, 2022

Interestingly, as soon as I am trying to push changes to the main repo (i.e. the one that hosts the workflow) it goes smoothly.

Yeah this is consistent with my own testing.

To be clear, I was able to eventually get it to work by adjusting the remote address for origin to be https://${{ secrets.GH_TOKEN }}@github.com/user/repo.git. Then you are able to push to a repo that isn't the one associated with the running action.

But this is the only solution I was able to come up with.

@yardenshoham
Copy link

I'm also seeing this issue, any idea what to do?

@kota65535
Copy link

kota65535 commented Feb 26, 2023

Hi there, I'm facing the same problem.
As far as I have tested locally, setting git config user.password to the personal access token no longer works now.
I don't know exactly when it stopped working, but maybe this announcement is related to this issue.
I think there are two solutions.

  • Replace all remote URLs of GitHub (as @paw-lu said above)
git config --global url."https://${INPUT_TOKEN}@github.com".insteadOf "https://github.com"
  • Set Authorization header for all remote URLs of GitHub
git config --global http.https://github.com.extraheader "Authorization: Basic $(base64 <<< "${INPUT_TOKEN}:")"

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

No branches or pull requests

4 participants