Checkout fails in CI with "[email protected]: Permission denied (publickey). fatal: Could not read from remote repository." for a submodule.

BeginnerTroubleshootingPipeline outages
Answer

Likely causes → The job's credentials can read the main repo but not the submodule. GITHUB_TOKEN is scoped to the current repository, and an SSH deploy key works for one repo only. The submodule URL may also be SSH while the runner only has an HTTPS token.

Diagnose →

cat .gitmodules
git config --get-regexp 'url\..*insteadOf'

Fix → Give checkout a credential with access to both, such as a GitHub App installation token or a fine-grained PAT, and use HTTPS URLs:

- uses: actions/checkout@v4
  with:
    submodules: recursive
    token: ${{ steps.app-token.outputs.token }}

Prevent → Use relative or HTTPS submodule URLs and GitHub App tokens (short-lived) rather than personal keys tied to someone's account.

All Real-World Interview questions Roadmap: Interview readiness

More on Pipeline outages