You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support private repositories and private submodules #287
It would be good if the checkout action would support some option to provide a different SSH_KEY for private submodules. E.g. SUBMODULE_SSH_KEY could be an organisation level SSH Key that allows pulling the repos.
Reacted by Gaétan Collaud, fk, Genghis Yang, CC, Brenno Henrique Santos Oliveira, Felipe S. S. Schneider, Gesugao-san, Peter, MaloMaisonneuve and René Schwaiger
Reacted by vincenthsh, tailaiw, Kamal Kamalaldin, Fabián Heredia Montiel, Nathan Pennie and Janne Kujanpää
Reacted by Brenno Henrique Santos Oliveira and Felipe S. S. Schneider
Thanks @marcofranssen, this is just want I needed. this is a partial solution.
For anyone else looking, deploy keys are a partial fix.
The problem with deploy keys and a separate clone submodules step is that you need to keep the submodule ref and the ref in github actions the same, editing the setting in two places.
Personal access tokens as suggested by @beroso work, but either involve giving access to all your repos, or creating a new machine user and adding them as a collaborator, big faff.
It would be great if github could provide a proper and simple way to clone private submodules.
Reacted by Marco Franssen, André Sousa, Nathan Lilienthal, zees-dev, Aditya Telange, Ken Morse, Swaraj, Dexter Lakin, Max, Miguel Calderon and 42 more
Reacted by Richard T. Miles, Dennis Roche, Max, Brano Zarnovican, Jan Peter, Gesugao-san, Fabian Kirschner, Dan Raviv, Tony Xiao, harshaperugu and 6 more
For anyone else having trouble with this, I have a solution that doesn't require personal access tokens but keeps the reference to the child repo commit in one place (using git submodules)
although the action checks out master, the git submodule commands check out the correct commit, this avoids having to keep the ref in github actions.
Reacted by Ian Walters, Steve Loveless, Glenn Nagel, Shun Takagiwa (giwa / shun_tak), Mark Schuck, Wen Wei Tseng, Miguel Calderon, Nícolas Teixeira, Anatole, Luksys3 and 23 more
Reacted by Sebastian Rittau, Jasper Nygaard, Armin, Oleksii Furaiev, 1633605, Kim, Anatole, lifeoasis-latte, Olimbek Nizomov, Haga R. and 17 more
Reacted by vincenthsh, Alessandro Re, Maly Lemire, Michal Landsman, Jonathan, Thomas Passer Jensen, Kamal Kamalaldin, David Lounsbrough, Maarten Jacobs, Anton Osenenko and 20 more
Reacted by Aslam Anver and Sergiu Todirașcu
Reacted by Charles Lewis, Ashwin A Nayar, Oleksii Furaiev, Olimbek Nizomov, Aslam Anver, Mohamed Eldesouki and Niklas Gürtler
Reacted by Lorenzo Faivre, Mark and Olimbek Nizomov
For anyone else having trouble with this, I have a solution that doesn't require personal access tokens but keeps stores the reference to the child repo commit in one play (using git submodules)
Correct me if I'm wrong, but this wont work for multiple private submodules, because each needs their own deploy key.
Reacted by Stephen Buck, Software-Challenge Deployment Bot, Ashwin A Nayar, Brano Zarnovican, Todd Smith, Mike Pountney, Jakob Lindner, Dave Hurley, Dan Raviv, Tomas Sandven and 6 more
I ended up just embedding the private keys for read-only deploy keys in the yml workflow files directly as ENV variables then following this advice with the hard coded strings instead of secrets (which aren't available for free in GitHub Org private repos): https://rgoswami.me/posts/priv-gh-actions/
I ended up just embedding the private keys for read-only deploy keys in the yml workflow files directly as ENV variables then following this advice with the hard coded strings instead of secrets (which aren't available for free in GitHub Org private repos): https://rgoswami.me/posts/priv-gh-actions/
Hacky and gross, but it works.
Less hacky and gross variant, using ssh-agent instead of writing to a file inside .ssh:
It's a travesty really that this doesn't work out of the box. It forces behaviors that should be discouraged - people fret about submodules (they shouldn't), people have to pay for dummy GitHub accounts just to make this work, people have to bend backwards to get something that is well within the minimally viable product spec for any CI environment. /smh
Reacted by Simone Chiesi, Lucas Vieira, Luca Gibelli, Rodrigo Chacon, Mark Roberts, Simon Adameit, Todd Smith, Adam Hegedus, Tony Apuzzo, Miles Granger and 61 more
I tend to use deployment keys for this. Add the pub key to the submodule repo; add the pri key to the main repo as a base64 encoded secret. Tokens are fine but seem like they ave too much access. SSH keys (with: ssh-key: in the action itself don't work well for me either because I have to use a global one. This is more surgical. Then something like this works:
What if the checkout action allowed you to specify exactly which submodule to check out?...
For some simple projects this might work out but in our case this would generate significant overhead. We are in a corporate environment where we're source-sharing some repositories across departments (every department is an org). Additionally we are having reusable workflows for some common CI/CD needs used across repositories.
Requiring manual individual checkout calls for the submodules does not scale well. As we'd need to manage for every repository duplicated the submodules in the CI/CD area for auth purposes.
Generating tokens for all orgs and passing a owner+token tuple is fairly easy achievable.
We pay for GitHub for Enterprise, and we can't even check out internal submodules. What a joke? And the secure way is to use PATs or SSH keys ? Does anybody at GitHub even know about this thread?
I don't understand why secrets.GITHUB_TOKEN isn't a thing here??
Reacted by Yaser Alraddadi, Michal Landsman, Florian Erbs, fullheart, Willy, Johannes Zillmann, Ighor July, Péter Balázs, Bryan Chu, Oleg V. Kozlyuk and 13 more
We pay for GitHub for Enterprise, and we can't even check out internal submodules. What a joke? And the secure way is to use PATs or SSH keys ? Does anybody at GitHub even know about this thread? I don't understand why secrets.GITHUB_TOKEN isn't a thing here??
This is become a nightmare.
Please let the product owners of github security know! This "bug" is here 5 years already.
Reacted by Lenart Kos, Grzegorz Dziadkiewicz, Edy Liu, Gregoire Banderet, Péter Balázs, Oleg V. Kozlyuk, Spyros Psarras, DPH, fabienfl-anssi, Mike Roach and 7 more
Referring to my reply on another thread with same issue here and answering the same.
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.
@parth-hb I had one of my repositories setup similarly as yours but I believe Github wants us to use Github Apps.
2 weeks ago, I setup another private repo with a private submodule but this time I'm using Github Apps.
Here are the steps for Organization (it will be similar steps for personal account)
Go to Setting > Developer Settings > Create Github Apps > New Github Apps
Filled the required fields then set the permissions as below then Create Github Apps
Contents - Readonly
Metadata - Read-only
Go back to the Github Apps setting > General > Private keys > Generate private keys from the Github Apps created. A private key will be downloaded.
Install the Apps to the organization
Setup Github Actions' secrets. Repo > Setting > Secrets and variables > Actions : Add APP_ID with the value from Github app settings and SUBMODULE_PRIVATE_KEY where the content of the private key
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.
So I stumbled across this you can use git+http in your git path to pass in an access token. See here in Vercel guide. https://vercel.com/guides/using-private-dependencies-with-vercel
It is difficult for me to understand why Github requires this much work to check out submodules, when they exist within the same private organization as the parent.
I've spent a day setting up a workaround. While hacking this workaround, I also accidentally leaked secrets.
Not a good look, Github.
EDIT including my solution
- name: Mask Github app id
run: |
echo "::add-mask::$(cat /my-mounted-secrets/github_app_id)"
- name: Mask Github app credentials key line by line
run: |
while IFS= read -r line; do
echo "::add-mask::$line"
done < /my-mounted-secrets/github_app_private_key
- name: save Github app id
id: gh_app_id
run: |
echo "value=$(cat /my-mounted-secrets/github_app_id)" >> $GITHUB_OUTPUT
- name: save Github app credentials key
id: gh_app_key
run: |
{
echo "value<<EOF"
cat /my-mounted-secrets/github_app_private_key
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create token with access to all private repositories
uses: actions/create-github-app-token@v1
id: private_access_token
with:
app-id: ${{ steps.gh_app_id.outputs.value }}
private-key: ${{ steps.gh_app_key.outputs.value }}
owner: ${{ github.repository_owner }}
Reacted by Michal Landsman, Florian Erbs and Maksim Koryukov
It is difficult for me to understand why Github requires this much work to check out submodules, when they exist within the same private organization as the parent.
I've spent a day setting up a workaround. While hacking this workaround, I also accidentally leaked secrets.
Not a good look, Github.
It's really stupid, yeah!
Reacted by Florian Erbs, János de Vries, Bolay Michael, Anthony Roach, Michael A. Eriksen, Mike Evans, Daniel Thaagaard Andreasen, Marcelo Fernández and Maksim Koryukov
Struggled with this a little today. Might have found something.
Followed @parth-hb's instructions for generating an SSH key to use as both the "deploy key" in the private submodule repo, and a secret in the public repo.
I edited .gitmodules in the public repo to use an SSH url (i.e. git@github: instead of https://github.com/). Then, the following worked:
However, that is not how I want to set up my local workflow. So, I found another alternative, setting up an SSH agent and using git config to change the url after the public repo was checked out.
We pay for GitHub for Enterprise, and we can't even check out internal submodules. What a joke? And the secure way is to use PATs or SSH keys ? Does anybody at GitHub even know about this thread? I don't understand why secrets.GITHUB_TOKEN isn't a thing here??
1 year after, sep 2026, i still need to call my shaman to configure access to submodules from the same organization (because even the org's "owner"-role members can't really help). The only "safe" alternative - create and configure org-wide github application and still - config is not much easier than creating deploy keys.
Activity
beroso commentedon Jul 16, 2020
This worked for me:
#116 (comment)
samuelcolvin commentedon Aug 16, 2020
Thanks @marcofranssen,
this is just want I needed.this is a partial solution.For anyone else looking, deploy keys are a partial fix.
The problem with deploy keys and a separate clone submodules step is that you need to keep the submodule ref and the ref in github actions the same, editing the setting in two places.
Personal access tokens as suggested by @beroso work, but either involve giving access to all your repos, or creating a new machine user and adding them as a collaborator, big faff.
It would be great if github could provide a proper and simple way to clone private submodules.
samuelcolvin commentedon Oct 12, 2020
For anyone else having trouble with this, I have a solution that doesn't require personal access tokens but keeps the reference to the child repo commit in one place (using git submodules)
although the action checks out master, the
git submodulecommands check out the correct commit, this avoids having to keep therefin github actions.elhedran commentedon Oct 21, 2020
See, this is what I really want... just the persist-credentials part. then I could have
and all it does is make it so the next git command or ssh command can use that key.
Add a GitHub Personal Access Token
Fix: private submodule cloning in GH action
Aschen commentedon Feb 17, 2021
Instead of using an SSH key (:scream: ) you can simply use a personal access token:
Here the
ACCESS_TOKENvariable is a personal access tokennixpulvis commentedon Mar 6, 2021
Correct me if I'm wrong, but this wont work for multiple private submodules, because each needs their own deploy key.
samuelcolvin commentedon Mar 7, 2021
I ended up building a rudimentary private package manager for python to get round this problem.
I think the reason github aren't fixing it is that they think the long term solution should be their package manager(s).
nixpulvis commentedon Mar 9, 2021
I ended up just embedding the private keys for read-only deploy keys in the yml workflow files directly as ENV variables then following this advice with the hard coded strings instead of secrets (which aren't available for free in GitHub Org private repos): https://rgoswami.me/posts/priv-gh-actions/
Hacky and gross, but it works.
WIP
[from now] 2021/04/29 19:43:56
davidbonnet commentedon Jul 9, 2021
Less hacky and gross variant, using
ssh-agentinstead of writing to a file inside.ssh:KubaO commentedon Aug 20, 2021
It's a travesty really that this doesn't work out of the box. It forces behaviors that should be discouraged - people fret about submodules (they shouldn't), people have to pay for dummy GitHub accounts just to make this work, people have to bend backwards to get something that is well within the minimally viable product spec for any CI environment. /smh
jleach commentedon Sep 3, 2021
I tend to use deployment keys for this. Add the
pubkey to the submodule repo; add theprikey to the main repo as a base64 encoded secret. Tokens are fine but seem like they ave too much access. SSH keys (with: ssh-key:in the action itself don't work well for me either because I have to use a global one. This is more surgical. Then something like this works:49 remaining items
Danielku15 commentedon Jan 7, 2025
For some simple projects this might work out but in our case this would generate significant overhead. We are in a corporate environment where we're source-sharing some repositories across departments (every department is an org). Additionally we are having reusable workflows for some common CI/CD needs used across repositories.
Requiring manual individual checkout calls for the submodules does not scale well. As we'd need to manage for every repository duplicated the submodules in the CI/CD area for auth purposes.
Generating tokens for all orgs and passing a owner+token tuple is fairly easy achievable.
p10tyr commentedon May 27, 2025
We pay for GitHub for Enterprise, and we can't even check out internal submodules. What a joke? And the secure way is to use PATs or SSH keys ? Does anybody at GitHub even know about this thread?
I don't understand why
secrets.GITHUB_TOKENisn't a thing here??landsman commentedon May 28, 2025
This is become a nightmare.
Please let the product owners of github security know! This "bug" is here 5 years already.
parth-hb commentedon Jun 30, 2025
Referring to my reply on another thread with same issue here and answering the same.
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:
jcampbell05 commentedon Jul 2, 2025
I think if anyone wants to do it I suppose an app could be made which Github then builds in
#287 (comment)
wwangsa commentedon Jul 2, 2025
@parth-hb I had one of my repositories setup similarly as yours but I believe Github wants us to use Github Apps.
2 weeks ago, I setup another private repo with a private submodule but this time I'm using Github Apps.
Here are the steps for Organization (it will be similar steps for personal account)
APP_IDwith the value from Github app settings andSUBMODULE_PRIVATE_KEYwhere the content of the private keyjayshrivastava commentedon Jul 6, 2025
@parth-hb thanks for investigating! I followed the instructions but it doesn't seem to work. I get
git@github.com: Permission denied (publickey)edit: I found the fix
My PR had a source branch in a fork, which was not getting secrets.
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.
elaboy commentedon Aug 14, 2025
Insane how this is still an issue...
jcampbell05 commentedon Aug 15, 2025
So I stumbled across this you can use
git+httpin your git path to pass in an access token. See here in Vercel guide.https://vercel.com/guides/using-private-dependencies-with-vercelgreenmoss commentedon Sep 24, 2025
It is difficult for me to understand why Github requires this much work to check out submodules, when they exist within the same private organization as the parent.
I've spent a day setting up a workaround. While hacking this workaround, I also accidentally leaked secrets.
Not a good look, Github.
EDIT including my solution
landsman commentedon Sep 24, 2025
It's really stupid, yeah!
jcampbell05 commentedon Jan 24, 2026
GitHub already created a solution for this but for some reason you can only use it for private actions
https://docs.github.com/en/actions/how-tos/reuse-automations/share-across-private-repositories
Can’t they just take this feature and enable it for all code
poocat commentedon Mar 9, 2026
Struggled with this a little today. Might have found something.
Followed @parth-hb's instructions for generating an SSH key to use as both the "deploy key" in the private submodule repo, and a secret in the public repo.
I edited
.gitmodulesin the public repo to use an SSH url (i.e.git@github:instead ofhttps://github.com/). Then, the following worked:However, that is not how I want to set up my local workflow. So, I found another alternative, setting up an SSH agent and using
git configto change the url after the public repo was checked out.maxkoryukov commentedon Sep 13, 2026
1 year after, sep 2026, i still need to call my shaman to configure access to submodules from the same organization (because even the org's "owner"-role members can't really help). The only "safe" alternative - create and configure org-wide github application and still - config is not much easier than creating deploy keys.