[GH-ISSUE #977] Issue: Git commands on private repos cause act to hang up #572

Open
opened 2026-03-01 21:44:38 +03:00 by kerem · 6 comments
Owner

Originally created by @ajrice6713 on GitHub (Feb 3, 2022).
Original GitHub issue: https://github.com/nektos/act/issues/977

System information

  • Operating System: macOS latest
  • Architecture: x64 (64-bit)
  • Apple M1: no
  • Docker version: 20.10.12
  • Docker image used in act: ghcr.io/catthehacker/ubuntu
  • act version: act version 0.2.25

Expected behaviour

Should be able to clone/push to private repositories in act

Actual behaviour

Act simply stops dead in its tracks on git clone or git push`

Workflow and/or repository

Workflow Example

name: Listner Test

on:
  workflow_call:
    inputs:
      branch_name:
        description: 'Branch name passed from the caller workflow'
        required: true
        type: string
 
 workflow_dispatch: 
    inputs:
      branch_name:
        description: 'Branch name passed from the caller workflow'
        required: true
        type: string

jobs:
  run_listner_test:
    name: Publish Staging Docsite
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Create and Push Branch
      run: |
        git checkout -b ${{ github.event.inputs.branch_name }}
        mkdir dest-directory
        git clone --branch ${{ github.event.inputs.branch_name }} https://github.com/{my-org}/{my-private-repo} dest-directory
        rm -r dest-directory/*.
        git add .
        git commit -m "Clone Specs from my-private-repo repo"
        git push origin ${{ github.event.inputs.branch_name }}

Steps to reproduce

Call git clone or git pull on a private repository

act output

act -j run_listner_test --secret-file ./.secrets --eventpath ./listener.event
[Listner Test/Publish Staging Docsite] 🚀  Start image=ghcr.io/catthehacker/ubuntu:act-latest
[Listner Test/Publish Staging Docsite]   🐳  docker pull image=ghcr.io/catthehacker/ubuntu:act-latest platform= username= forcePull=false
[Listner Test/Publish Staging Docsite]   🐳  docker create image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Listner Test/Publish Staging Docsite]   🐳  docker run image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Listner Test/Publish Staging Docsite]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root workdir=
[Listner Test/Publish Staging Docsite]   🐳  docker cp src=/Users/arice/Documents/GitHub/my-repo/. dst=/Users/arice/Documents/GitHub/my-repo
[Listner Test/Publish Staging Docsite]   🐳  docker exec cmd=[mkdir -p /Users/arice/Documents/GitHub/my-repo] user= workdir=
[Listner Test/Publish Staging Docsite] ⭐  Run actions/checkout@v2
[Listner Test/Publish Staging Docsite]   ✅  Success - actions/checkout@v2
[Listner Test/Publish Staging Docsite] ⭐  Run Create and Push Branch
[Listner Test/Publish Staging Docsite]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /Users/arice/Documents/GitHub/api-docs-internal/workflow/1] user= workdir=
| Switched to a new branch 'test-branch'
| Cloning into 'dest-directory'...

The run just pauses here and never continues to the next step

I believe it is getting hung up on needing git credentials

I am setting GITHUB_TOKEN in a .env file

# .env file

GITHUB_TOKEN={my secret token}
Originally created by @ajrice6713 on GitHub (Feb 3, 2022). Original GitHub issue: https://github.com/nektos/act/issues/977 ## System information - Operating System: macOS latest - Architecture: x64 (64-bit) - Apple M1: no - Docker version: 20.10.12 - Docker image used in `act`: ghcr.io/catthehacker/ubuntu - `act` version: act version 0.2.25 ## Expected behaviour Should be able to clone/push to private repositories in act ## Actual behaviour Act simply stops dead in its tracks on `git clone` or git push` ## Workflow and/or repository ### Workflow Example ```yml name: Listner Test on: workflow_call: inputs: branch_name: description: 'Branch name passed from the caller workflow' required: true type: string workflow_dispatch: inputs: branch_name: description: 'Branch name passed from the caller workflow' required: true type: string jobs: run_listner_test: name: Publish Staging Docsite runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Create and Push Branch run: | git checkout -b ${{ github.event.inputs.branch_name }} mkdir dest-directory git clone --branch ${{ github.event.inputs.branch_name }} https://github.com/{my-org}/{my-private-repo} dest-directory rm -r dest-directory/*. git add . git commit -m "Clone Specs from my-private-repo repo" git push origin ${{ github.event.inputs.branch_name }} ``` ## Steps to reproduce Call git clone or git pull on a private repository ## `act` output ```none act -j run_listner_test --secret-file ./.secrets --eventpath ./listener.event [Listner Test/Publish Staging Docsite] 🚀 Start image=ghcr.io/catthehacker/ubuntu:act-latest [Listner Test/Publish Staging Docsite] 🐳 docker pull image=ghcr.io/catthehacker/ubuntu:act-latest platform= username= forcePull=false [Listner Test/Publish Staging Docsite] 🐳 docker create image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [Listner Test/Publish Staging Docsite] 🐳 docker run image=ghcr.io/catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[] [Listner Test/Publish Staging Docsite] 🐳 docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root workdir= [Listner Test/Publish Staging Docsite] 🐳 docker cp src=/Users/arice/Documents/GitHub/my-repo/. dst=/Users/arice/Documents/GitHub/my-repo [Listner Test/Publish Staging Docsite] 🐳 docker exec cmd=[mkdir -p /Users/arice/Documents/GitHub/my-repo] user= workdir= [Listner Test/Publish Staging Docsite] ⭐ Run actions/checkout@v2 [Listner Test/Publish Staging Docsite] ✅ Success - actions/checkout@v2 [Listner Test/Publish Staging Docsite] ⭐ Run Create and Push Branch [Listner Test/Publish Staging Docsite] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /Users/arice/Documents/GitHub/api-docs-internal/workflow/1] user= workdir= | Switched to a new branch 'test-branch' | Cloning into 'dest-directory'... ``` The run just pauses here and never continues to the next step I _believe_ it is getting hung up on needing git credentials I am setting GITHUB_TOKEN in a .env file ``` # .env file GITHUB_TOKEN={my secret token} ```
Author
Owner

@ajrice6713 commented on GitHub (Feb 3, 2022):

Running inside of Github Actions i get fatal: could not read Username for 'https://github.com/': No such device or address

Assuming that this is what act is encountering and just not surfacing to the user

I believe my syntax is also incorrect in that i should be using `git clone git@github.com:{username}/{repo}

but i still believe that this error not being surfaced to the user is a bug

<!-- gh-comment-id:1029384787 --> @ajrice6713 commented on GitHub (Feb 3, 2022): Running inside of Github Actions i get `fatal: could not read Username for 'https://github.com/': No such device or address` Assuming that this is what act is encountering and just not surfacing to the user I believe my syntax is also incorrect in that i should be using `git clone git@github.com:{username}/{repo} but i still believe that this error not being surfaced to the user is a bug
Author
Owner

@sosedoff commented on GitHub (Feb 13, 2022):

Indeed, when your action (or code) tries to clone from a HTTPS endpoint, act will hang waiting for the password prompt. You can set GIT_TERMINAL_PROMPT=0 in the top-level env in your workflow. The error you'll see will be slightly different.

fatal: could not read Username for 'https://github.com': terminal prompts disabled

I think this env var should be set (in act) by default since github actions are non-interactive anyway.

<!-- gh-comment-id:1037608650 --> @sosedoff commented on GitHub (Feb 13, 2022): Indeed, when your action (or code) tries to clone from a HTTPS endpoint, `act` will hang waiting for the password prompt. You can set `GIT_TERMINAL_PROMPT=0` in the top-level `env` in your workflow. The error you'll see will be slightly different. ``` fatal: could not read Username for 'https://github.com': terminal prompts disabled ``` I think this env var should be set (in act) by default since github actions are non-interactive anyway.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 16, 2022):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:1068587072 --> @github-actions[bot] commented on GitHub (Mar 16, 2022): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@BenjaminYdeVintecc commented on GitHub (Mar 2, 2023):

Same issue here.
It hangs when i want to do gh repo clone <my-repo>
Even have the issue when using gh auth login (with token) before the clone.

A workaround could be using the following line
git clone https://<username>:<PAT>@github.com/<owner>/<repo>.git

<!-- gh-comment-id:1451561599 --> @BenjaminYdeVintecc commented on GitHub (Mar 2, 2023): Same issue here. It hangs when i want to do `gh repo clone <my-repo>` Even have the issue when using gh auth login (with token) before the clone. A workaround could be using the following line `git clone https://<username>:<PAT>@github.com/<owner>/<repo>.git`
Author
Owner

@drew-viles commented on GitHub (Mar 3, 2023):

For anyone still struggling with using private repos, I was building a docker image and scanning with Grype. The building of the docker image required pulling the Dockerfile from the private repo.

When running this with no env vars I'd get:
fatal: could not read Username for 'https://github.com': terminal prompts disabled

My solution to this was to run:

GIT_TERMINAL_PROMPT=0
act -j <job_name> -s GITHUB_TOKEN=<github_pat_token>

This allowed the job to succeed.

Hope this helps.

<!-- gh-comment-id:1453260120 --> @drew-viles commented on GitHub (Mar 3, 2023): For anyone still struggling with using private repos, I was building a docker image and scanning with Grype. The building of the docker image required pulling the Dockerfile from the private repo. When running this with no env vars I'd get: ```fatal: could not read Username for 'https://github.com': terminal prompts disabled``` My solution to this was to run: ``` GIT_TERMINAL_PROMPT=0 act -j <job_name> -s GITHUB_TOKEN=<github_pat_token> ``` This allowed the job to succeed. Hope this helps.
Author
Owner

@f0lie commented on GitHub (Jan 16, 2025):

I am encounter a similar problem but this time the repo isn't private. Again I am stalling at git push origin..

I have tried to use GIT_TERMINAL_PROMPT=0 but that work around didn't work.

    - name: Commit and push changes if markdown files were created
      run: |
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"

        echo "Adding files to staging area..."
        git add **/ven_anigha_reddit_archive_* reddit_comments.db --verbose
        echo

        # Check if there are changes to commit
        if git diff --cached --quiet; then
          echo "No changes to commit."
        else
          echo "Committing changes..."
          git commit -m "Update Reddit comments and markdown files" --verbose
          echo

          echo "Latest commit log:"
          git --no-pager log -1 --stat
          echo

          echo "Pushing changes to remote repository..."
          git push origin HEAD:${{ github.ref }} --verbose
        fi
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
<!-- gh-comment-id:2594219847 --> @f0lie commented on GitHub (Jan 16, 2025): I am encounter a similar problem but this time the repo isn't private. Again I am stalling at `git push origin..` I have tried to use `GIT_TERMINAL_PROMPT=0` but that work around didn't work. ``` - name: Commit and push changes if markdown files were created run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" echo "Adding files to staging area..." git add **/ven_anigha_reddit_archive_* reddit_comments.db --verbose echo # Check if there are changes to commit if git diff --cached --quiet; then echo "No changes to commit." else echo "Committing changes..." git commit -m "Update Reddit comments and markdown files" --verbose echo echo "Latest commit log:" git --no-pager log -1 --stat echo echo "Pushing changes to remote repository..." git push origin HEAD:${{ github.ref }} --verbose fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#572
No description provided.