When checking out a repo on Github Actions workflow, how do I pass in a key for a private submodule but not the repo itself? #928
-
When checking out a repo on Github Actions workflow, how do I pass in a key for a private submodule but not the repo itself? This is currently how I am doing it: The - uses: actions/checkout@v3
with:
submodules: 'true'
ssh-key: ${{ secrets.ACCESS_KEY }} |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 28 replies
-
Same here. The main repo should always use the provided $GITHUB_TOKEN. I guess a workaround is to setup a machine user (service account) and use one user key for both main and submodule repo. In our case our organization has limited seats, so we don't want that. GHA is mostly used by organizations, so PATs don't apply here either. There are countless issues here about private submodules not working and I'm surprised it's not clearly documented. Why is there no SSH config option per submodule? Obviously we are missing something here. |
Beta Was this translation helpful? Give feedback.
-
Associated issue: #924 |
Beta Was this translation helpful? Give feedback.
-
This following configuration is working for me, although it is unfortunate this required an additional action: - uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.PULL_KEY_REPO }}
${{ secrets.PULL_KEY_SUBMODULE_OTHERREPO }}
- uses: actions/checkout@v3
with:
submodules: 'recursive'
persist-credentials: false
Everything is tightly scoped so that this repo/action can only access repos for which it has a deploy key. I would not recommend sharing deploy keys between multiple actions/repos. This method also pulls public HTTPS submodules just fine. |
Beta Was this translation helpful? Give feedback.
-
This worked for me: `
|
Beta Was this translation helpful? Give feedback.
I got it to work on Windows by doing the submodule checkout manually. I also had to register the ssh keys after the initial checkout because for some reason it couldn't pull the action repo. This is what I did...