checkout: Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
Hello,
I’m attempting a rollback flow using actions/checkout@v2. The problem is that I need to use a PAT in order to rollback commits that change Github Workflows and when I pass that PAT into actions/checkout, I get an error.
Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
My workflow:
name: "Dev Deploy"
on:
workflow_run:
workflows: ["Versioning"]
types: [completed]
jobs:
fail_job:
runs-on: ubuntu-latest
steps:
- name: Fail
run: |
exit 1
rollback-on-failure:
runs-on: ubuntu-latest
needs: [fail_job]
if: always() && needs.fail_job.result == 'failure'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}
- run: chmod +x environment/rollback.sh && ./environment/rollback.sh
The PAT used has the permissions to change workflows, as well as repository permissions. The issue seems to be that the action doesn’t allow me to set a username before it tries to fetch the repository.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 82
- Comments: 51
Commits related to this issue
- follow advice in actions/checkout#664 — committed to myk002/dfhack by myk002 4 years ago
- follow advice in actions/checkout#664 — committed to DFHack/dfhack by myk002 4 years ago
- trying no token https://github.com/actions/checkout/issues/664#issuecomment-1273429586 — committed to eca21x/HelpDesk by kangwon-naver 3 years ago
- try checkoutv2 per https://github.com/actions/checkout/issues/664 — committed to stefanhaustein/TerminalImageViewer by aaronliu0130 3 years ago
- ci: Fallback to actions/checkout@v2 Apparently there are issues with v3 not being able to checkout with `PUSH_KEY`? https://github.com/actions/checkout/issues/664 — committed to francorbacho/cheng by francorbacho 3 years ago
- fix(git): unexpected git push error: fatal: could not read Username for 'https://github.com': No such device or address @see: https://github.com/actions/checkout/issues/664 — committed to DSI-HUG/actions by Badisi 2 years ago
- Use the PAT for pushing changes correctly Using action/checkout with token is broken for our usecase, implemented a workaround from: https://github.com/actions/checkout/issues/664#issuecomment-18768... — committed to grafana/pyroscope by simonswine 2 years ago
- chore: Another try to fix update-contributors (#3515) * Newline after contributors * Use the PAT for pushing changes correctly Using action/checkout with token is broken for our usecase, implem... — committed to grafana/pyroscope by simonswine 2 years ago
Another hint: The PAT must have an expiry date, otherwise the same error appears 😅.
I’m also experiencing the same issue. I wanted to add a checkout of another private repo, that lives in the same organisation as the original private repo which the workflow is in.
My code:
Results:
Checkout the private repo in which the workflow lives✔️Checkout a public repo to see if it works✔️Checkout another private repo in the same organisation❌The error:
I stumbled into the same error message and found this issue. However in my case, the cause of the problem was that the token expired. 😅 Adding it here, in case it helps folks. The error message is very undescriptive.
I needed to auto-create a release for my private golang repository, and came across this page in my investigations. Being new to github actions and workflows, I needed to resolve how to inject
https://$GH_TOKEN@github.cominstead ofhttps://github.comgitconfig statement into my workflow setup. Found this blog post which exactly solved my issue. Posting here in case someone else needs a pointermy 2 cents: it would be great that github checkout action automatically detect this kind of error return to provide a tips on this: (example:
please verify your token and expiration date.I think in many case this is just “private” + “expired” or “wrong” PAT configuration?
@MichaIng Thanks for the tip! I wouldn’t have figured that out on my own. 😃
I was able to fix this by using a classic token with the permissions
public_repo,read:useranduser:email.Cheers
Using a token that doesn’t expire fixed this issue for me.
Could someone explain if there is some underlying reason why these tokens are rejected though?
If GitHub is going to reject tokens that don’t expire then they shouldn’t let you generate them in the first place.
@ScottG489 - have a look at this blog post. Seems there are 3 requirements for a valid token applied in actions.
You definitely use a PAT which has an expiry date and is not expired?
I got it working using checkout@v3 with
persist-credentials: falseand a PAT with expire date using the following config:Should the requirement to have an expiration date in the PAT be documented here? https://github.com/marketplace/actions/checkout#usage
Has anyone found a solution to this issue? I have the same error and nothing seems to work
I am having the same issue. It only happens for PRs created by dependabot though, and the strange thing is that if I close the PR and then reopen it, then it works. I have tried to apply all fixes suggested here, but nothing seems to work.
Update: I got it working now. I just realised that I had to update the PAT in two places - both for the actions and for dependabot.
same issue here with a PAT
It started working again for me after some time. Probably a misconfig and the cache got erased after a while.
I was stuck for an hour or two yesterday with this problem, and the cause was that I wrote
${ secrets.XXX }where I should have written${{ secrets.XXX }}. Sometimes the PAT expiration is the cause of this error, sometimes it is not, so if you are having problems, I would recommend checking from various perspectives.The layers of their javascript between you and a
gitcommand will not be updated to make more friendly error messages upon failure.Instead, if you add a step to your own workflow you can emit helpful action items for when errors occur and save your future self from wasting time.
You can verify your Personal Access Token is not expired and has proper permissions:
GitHub:
GitHub Enterprise:
So for instance:
So write a quick script to use as a step in your workflow:
this is one of those ‘why is nothing easy / the world is against me’ problems. the comment from @frans-slabbekoorn fixed it for me. Thank you to others who mentioned the PAT requiring an expiry date.
I had the same error on multiple repositories. Tried checkout@v3 and v4, but result was the same. For me, replacing the Action secret in each repository with a new Personal Access Token (with expiration) solved it.
Looks like I found the root cause of this behavior. When the first actions/checkout@v2 performs without any options for current repository it caches github token in local git store and further the same token is used. I added flag “persist-credentials: false” to the first checkout step and further steps with github communications started work (ad-m/github-push-action or simple git push https://user:token@github/org/repo). Looks like git cli ignores incoming token if it is already stored in local storage… At lest it helped me… 😃 p.s. username does not matter when token is used…
Personally I didn’t have a PAT in my GitHub workflow and it worked fine till 2 weeks ago for simple checkout, so not sure what happened on GitHub side here.
I’m having the same problem as MikulasMascautanu, but I don’t think there’s anything wrong with my PAT. I’m only getting this error on one private repo in the entire organization. Every other repo in the same organization is completing its actions just fine, and they all use an identical CI yaml (the only difference being that this one specifies a working directory).
Is there some repo setting in Github that I might need to change?
For a simple checkout indeed no PAT is required.
Hi, sorry for my late response. I did NOT solve the issue, I used a different approach for my original task. Sorry:/