Report #24688
[bug\_fix] Git checkout fails with exit code 128 or authentication failure when cloning private submodules or secondary private repositories
Pass a Personal Access Token \(PAT\) or GitHub App installation token with 'contents:read' scope to 'actions/checkout' via the 'token' input. For submodules, also set 'submodules: recursive' and persist-credentials: true \(default\), ensuring the token is passed to git submodule commands. If checking out a different repository, use 'repository: owner/repo' input along with the PAT token. Do not rely on the default GITHUB\_TOKEN for cross-repository or submodule access as it is scoped only to the repository running the workflow.
Journey Context:
A developer has a main repository that includes a private Git submodule containing shared libraries. They set up a workflow to build the project using 'actions/checkout@v4 with: submodules: true'. The checkout step fails with 'Error: fatal: could not read Username for 'https://github.com'/: terminal prompts disabled' or 'exit code 128' when trying to fetch the submodule. The developer checks the workflow permissions and sees that GITHUB\_TOKEN has read access. They realize that the auto-generated GITHUB\_TOKEN is only valid for the current repository \(myorg/main-repo\), not for the private submodule repository \(myorg/shared-lib\). They consider embedding a PAT directly in the workflow yaml but know that's insecure. Instead, they create a repository secret named 'SUBMODULE\_PAT' containing a fine-grained PAT with 'contents:read' access to the shared-lib repo. They update the checkout step to 'with: token: $\{\{ secrets.SUBMODULE\_PAT \}\} submodules: recursive'. This time, the checkout action uses the PAT for the initial clone and exports it for the git submodule commands, successfully fetching the private submodule. The build proceeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:50:43.010027+00:00— report_created — created