EndBug/add-and-commit

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

coderaiser opened this issue ยท 14 comments

Thank you for such a useful action :). It worked well, but today I trapped on an issue.

Describe the bug
Job is failed, action cannot push to repository.

Workflow used

Internal logs
  > Staging files...
  > Adding files...
  > No files to remove.
  > Checking for uncommitted changes in the git working tree...
  > Found 1 changed files.
  { raw: '', remote: null, branches: [], tags: [] }
  > Switching/creating branch...
  M	package.json
  Branch 'master' set up to track remote branch 'master' from 'origin'.
  
  > Pulling from remote...
  { raw: '', remote: null, branches: [], tags: [] }
  PullSummary {
    remoteMessages: RemoteMessageSummary { all: [] },
    created: [],
    deleted: [],
    files: [],
    deletions: {},
    insertions: {},
    summary: { changes: 0, deletions: 0, insertions: 0 }
  }
  > Re-staging files...
  > Creating commit...
  {
    author: null,
    branch: 'master',
    commit: 'd05199db',
    summary: { changes: 1, insertions: 1, deletions: 2 }
  }
  > No tag info provided.
  > Pushing commit to repo...
  Error: Error: Pushing to https://github.com/coderaiser/putout
  fatal: could not read Username for 'https://github.com': No such device or address
  
Outputs
  committed: true
  pushed: false
  tagged: false
Error: Error: Pushing to https://github.com/coderaiser/putout
fatal: could not read Username for 'https://github.com': No such device or address

Here is current config.

Expected behavior
I expect that fixes will be pushed to repo.

Hi, I've tried to reproduce your issue and I think that it might be caused by the fact that you're running the action on every run of the matrix, and GitHub might have some issues with that (I'm able to reproduce the error using a matrix strategy).
I think that it's better if you run your tests on the matrix, then you can run another job dedicated to linting & stuff (I think it would be better anyway, even if everything worked fine).

Let me know if you're able to solve the issue!

Could you please help me, what should I change to run job dedicated to linting after matrix?

You could have a job that only runs tests (which in your case seem to only be running the build), and that will use the matrix strategy.

Then you can create a second job, with all the steps that you need to use to update the repo, which include my action. This second job should run only once, with no matrix.

Here's the outline of the workflow:

jobs:
  test:
    strategy:
      matrix:
        node-version: [14.x, 15.x]
    steps:
    # checkout, node, ...

  lint:
    steps:
    # run linter, add-and-commit, ...

Thank you @EndBug, I'll give it a try :).

Did you find a resolution to this? I'm getting an identical error with a completely different workflow

I also had a similar issue in this run. Not sure where's the problem..

@Fadelis I honestly have no idea of why it's happening. Here's what I thought:

  • If the git URL was wrong, then it would have failed when the action pulled from the remote, so that can't be the case
  • The username could be the problem, but you're using the default option, and you're listed regularly as the GitHub actor in the run summary.
    Just one thing: you're hiding your private email on GitHub, right? Because I see that GitHub is censoring the username and email in the logs, and the only valid reason is that you're using GitHub's profile email. If that's the case then it's ok, otherwise, we'd need to look into it...

I guess I'll open an issue in https://github.com/steveukx/git-js, since that's the package I'm using: they should at least be able figure out if the problem is in my implementation.

Let me know about the email thing.

Well I don't have the Keep my email addresses private box ticked, but also I don't have a public display email selected, so maybe that could be the problem. Next time I'll try to update the flow to use the github-actions user instead of a personal one.

@Fadelis Let me know if that changes anything ๐Ÿ‘๐Ÿป

same issue, no matrix, here's the workflow file

name: PlantUML
on:
  push:
    paths:
      - '**.puml'
jobs:
  plantuml:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Get changed UML files
        id: getfile
        run: |
          echo "::set-output name=files::$(git diff-tree -r --no-commit-id --name-only ${{ github.sha }} | grep '.puml' | xargs)"
      - name: UML files considered echo output
        run: |
          echo ${{ steps.getfile.outputs.files }}
      - name: Generate SVG Diagrams
        uses: cloudbees/plantuml-github-action@master
        with:
          args: -v -tsvg ${{ steps.getfile.outputs.files }}
      - name: get remote branch name
        id: branch
        run: |
          BRANCH=$(echo $GITHUB_REF | cut --delimiter / --fields '3-')
          echo "::set-output name=name::$BRANCH"
      - uses: EndBug/add-and-commit@v7
        with:
          message: 'generate SVG for PlantUML'
          add: '*.svg'

and the output

Run EndBug/add-and-commit@v7
  with:
    message: generate SVG for PlantUML
    add: *.svg
    author_name: xenoterracide
    author_email: xenoterracide@users.noreply.github.com
    cwd: .
    pull_strategy: --no-rebase
    push: true
Running in /home/runner/work/ppm-backend/ppm-backend
Add input parsed as single string, running 1 git add command.
> Using 'xenoterracide <xenoterracide@users.noreply.github.com>' as author.
> Using "generate SVG for PlantUML" as commit message.
Internal logs
  > Staging files...
  > Adding files...
  > No files to remove.
  > Checking for uncommitted changes in the git working tree...
  > Found 1 changed files.
  { raw: '', remote: null, branches: [], tags: [] }
  > Switching/creating branch...
  A	user.svg
  Branch 'db-module' set up to track remote branch 'db-module' from 'origin'.
  
  > Pulling from remote...
  { raw: '', remote: null, branches: [], tags: [] }
  PullSummary {
    remoteMessages: RemoteMessageSummary { all: [] },
    created: [],
    deleted: [],
    files: [],
    deletions: {},
    insertions: {},
    summary: { changes: 0, deletions: 0, insertions: 0 }
  }
  > Re-staging files...
  > Creating commit...
  {
    author: null,
    branch: 'db-module',
    commit: 'bea4de1',
    summary: { changes: 1, insertions: 41, deletions: 0 }
  }
  > No tag info provided.
  > Pushing commit to repo...
  Error: Error: Pushing to https://github.com/xenoterracide/ppm-backend
  fatal: could not read Username for 'https://github.com': No such device or address
  
Outputs
  committed: true
  pushed: false
  tagged: false
Error: Error: Pushing to https://github.com/xenoterracide/ppm-backend

fixed by using a different action to push

name: PlantUML
on:
  push:
    paths:
      - '**.puml'
jobs:
  plantuml:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Get changed UML files
        id: getfile
        run: |
          echo "::set-output name=files::$(git diff-tree -r --no-commit-id --name-only ${{ github.sha }} | grep '.puml' | xargs)"
      - name: UML files considered echo output
        run: |
          echo ${{ steps.getfile.outputs.files }}
      - name: Generate SVG Diagrams
        uses: cloudbees/plantuml-github-action@master
        with:
          args: -v -tsvg ${{ steps.getfile.outputs.files }}
      - uses: EndBug/add-and-commit@v7
        with:
          message: 'generate SVG for PlantUML'
          add: '*.svg'
          push: false
      - uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}

@xenoterracide Well, of course you can use another action to push, you could also run git push directly.

I've tried editing the potential fix, according to what the author of simple-git told me, could you try it? @Fadelis @xenoterracide
It's EndBug/add-and-commit@fatal-fix-1

no, that didn't fix the problem, but moving to actions/checkout@v2 did (no patch needed). That was a pain though, it broke all of the git logic I had

@xenoterracide Whoa, I didn't even consider that that could be the issue! Looking back, every workflow that has been posted in this issue was using actions/checkout@v1. I'll add a warning in the README

Thanks a lot to everyone :)