Repository navigation
Closed
Labels
enhancementNew feature or request
Description
I've private git submodule, which contains our shared i18n resouces, with same organization owner as my main repo
I've configured git submodule in main repository as
$ cat .gitmodules
[submodule "xxx-i18n"]
path = xxx-i18n
url = ../xxx-i18n
branch = master
Then I added this one from README to my github action workflow.
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
I expected this to work.
Instead I got
Checkout submodules
2s
##[error]Process completed with exit code 1.
Run auth_header="$(git config --local --get http.https://github.com/.extraheader)"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
shell: /bin/bash --noprofile --norc -e -o pipefail {0}
Submodule 'xxx-i18n' (https://github.com/myprivateorg/xxx-i18n) registered for path 'xxx-i18n'
Cloning into '/home/runner/work/my-main-repo/my-main-repo/xxx-i18n'...
remote: Repository not found.
fatal: repository 'https://github.com/myprivateorg/xxx-i18n/' not found
fatal: clone of 'https://github.com/myprivateorg/xxx-i18n' into submodule path '/home/runner/work/my-main-repo/my-main-repo/xxx-i18n' failed
Failed to clone 'xxx-i18n'. Retry scheduled
Cloning into '/home/runner/work/my-main-repo/my-main-repo/xxx-i18n'...
remote: Repository not found.
fatal: repository 'https://github.com/myprivateorg/xxx-i18n/' not found
fatal: clone of 'https://github.com/myprivateorg/xxx-i18n' into submodule path '/home/runner/work/my-main-repo/my-main-repo/xxx-i18n' failed
Failed to clone 'xxx-i18n' a second time, aborting
##[error]Process completed with exit code 1.
Reacted by Ashwin V. Mohanan, Rodrigo Rodriguez, Juan Leni, epy0n0ff, Tyler, Samkit Jain, Maykonn Welington, Mark G., Shaun Jackman, Dan Macumber and 28 more
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
eberkund commentedon Dec 19, 2019
Sub-modules support was removed in v2, I'm not sure why though
https://github.com/actions/checkout/releases/tag/v2.0.0
tvainika commentedon Dec 19, 2019
I understood that it refers to another syntax
with: submodulesas the README I linked gives this new syntax I used.[-]submodule checkout fails @v2[/-][+]private submodule checkout fails @v2[/+]da1nerd commentedon Dec 27, 2019
I also need to have sub-module support. When I use v2, there's no
.gitdirectory so I cannot perform any commands like checking out sub-modules. For now I'm using v1 to continue my development.rodrigorn commentedon Dec 28, 2019
I have the exact same issue but I just made it work using the Checkout multiple repos (private) example
This is working just as a workaround and might not be practical for a project with a lot of submodules, but I hope it helps until #72 is resolved
ashwinvis commentedon Dec 28, 2019
@rodrigorn It works for some use cases. Even with a single submodule, it can become inconsistent when the master branch
myOrg/myRepoadds commits which are not tracked by the main repo.jleni commentedon Jan 2, 2020
This is actually blocking us from using GitHub actions. I hope it can be prioritized..
ericsciple commentedon Jan 2, 2020
@tvainika the default token embedded in the main repo does not have access to fetch other private repositories. Instead if you supply
token: ${{ secrets.MY_GITHUB_PAT }}then it should work.ericsciple commentedon Jan 2, 2020
@neutrinog no .git folder indicates git 2.18 or higher is not in your PATH. I updated the readme earlier today to make that more clear.
jleni commentedon Jan 5, 2020
@ericsciplec @rodrigorn is there a better alternative? I would like to avoid maintaining submodule hashes/branches in two different places. This is very error prone..
m-hilgendorf commentedon Jan 6, 2020
I'm having the same issue, came here from the readme where it has a section on "Checkout Submodules" that does not work at all for me (I can't checkout any submodule, public or private).
rodrigorn commentedon Jan 7, 2020
I agree completely but haven't found any better solution yet
Lauszus commentedon Jan 13, 2020
FYI this is what I have been using:
ashwinvis commentedon Jan 13, 2020
@Lauszus is the CI_TOKEN a personal access token?
Lauszus commentedon Jan 13, 2020
@ashwinvis yes it is. I have updated my comment to make it more clear.
68 remaining items
sfullerbeckman commentedon Sep 21, 2022
I get this error when trying to use your script...
The script look fine though. Do you know what the issue is @Lauszus ?
Lauszus commentedon Oct 3, 2022
From your error output it looks like you are running Windows. I don't think my script works with Windows.
include WarpRna
asaf-kali commentedon Apr 9, 2023
For anyone who gets here in the future, adding to @fbernaly's comment, when creating a PAT:
Repository access->Only select repositories-> Give access to both main repo and submodule repo.Permissions->Repository permissions-> GiveRead-onlyaccess toContentsandMetadata.richw-kai commentedon Jun 14, 2023
It's a little concerning that the only solution here is to create a PAT. The point of a Github Action is to centralise the deployment process for an organisation, that organisation may have multiple private repositories, for example defining graphql or protobuf contracts. They need importing into each repo during the build process as submodules. To rely on PAT for this process is a security concern as well as an availability risk. If the person who creates the PAT leaves the company, the whole company will now be unable to deploy due to a quite deep down and hidden error within this process.
What is the recommended solution for allowing an organisation to deploy code that references submodules from within their own organisation?
sfullerbeckman commentedon Jun 14, 2023
Oh that is true, @richw-kai. I didn't think of that issue with the PAT. I was so focussed on getting it to work in the first place!
charlielito commentedon Jun 14, 2023
Because of that, I use GitHub App Installation access tokens which are not directly tied to a user but instead tied to the GitHub App installed in your organization. I use this action to use a previously configured and installed GitHub App to get a special token with more privileges (like access to other organization repos). This other action also seems to do the same. Then, my action would look like:
mcolussi-bigw commentedon Aug 4, 2023
This worked for me and probably the best solution so far to not tie the submodule checkout permissions to a specific user. The only requirement is the GitHub App needs the read-only to the "Contents" permission.
Cloudef commentedon Sep 15, 2023
Can't believe there's still no better way to do this
zealcc commentedon Jan 29, 2024
how can i checkout submodules on pull reqeust ???
${{ github.token }} -> can't checkout submodules -> pull-request can use github.token
${{ secrets.GH_PAT }} -> can checkout submodules -> pull-request can't use secrets
sfullerbeckman commentedon Jan 29, 2024
This worked for me. After checking out the main repository, my pipeline runs this action to checkout any submodules. It's a little bit hacky, but it has worked for me.
parth-hb commentedon Jun 30, 2025
I faced same issue and struggled atleast 2 days to make it work. If you're also struggling with the same, here's a reliable and tested fix using Deploy Keys.
Steps
Generate an SSH Key
ssh-keygen -t rsa -b 4096 -C "ci-access" -f submodule_deploy_keyAdd Public Key to Submodule Repo
my-org/my-redux-store)Settings→Deploy Keyssubmodule_deploy_key.pubAdd Private Key to Main Repo Secrets
my-org/my-app)SUBMODULE_SSH_KEYsubmodule_deploy_key(the private key)Modify Workflow
Before updating submodules, add:
This should fix the common
Permission deniedorRepository not founderrors when dealing with submodules.Works great when:
parth-hb commentedon Jun 30, 2025
I faced same issue and struggled atleast 2 days to make it work. If you're also struggling with the same, here's a reliable and tested fix using Deploy Keys.
Steps
Generate an SSH Key
ssh-keygen -t rsa -b 4096 -C "ci-access" -f submodule_deploy_keyAdd Public Key to Submodule Repo
my-org/my-redux-store)Settings→Deploy Keyssubmodule_deploy_key.pubAdd Private Key to Main Repo Secrets
my-org/my-app)SUBMODULE_SSH_KEYsubmodule_deploy_key(the private key)Modify Workflow
Before updating submodules, add:
This should fix the common
Permission deniedorRepository not founderrors when dealing with submodules.Works great when:
davidt-gh commentedon Jul 8, 2025
Why is that closed if the issue never solved?
NicolasGonzalezFarabollini commentedon Jul 31, 2025
You can bypass this issue if you use the token inside a docker instance on github actions. Yes, not the most efficient, nor elegant. But it works.
For example, I just need to build a dependency from a private repo under same org. I make the yarn build inside the docker image, validate with token. Next, I extract the files from the docker image, and continue the build process with normal github steps.