Prerequisites:
- This guide assumes that you’re familiar with Git, generating SSH keys, and connecting a Git repository to your Valohai project. If you’re not familiar with these see our guide on Connect to a Git repository
Each Valohai project can be connected to one Git repository at a time.
Sometimes you might need to access another repository from your Valohai project. This could be because you’re developing a library separately in another Git repository or have some other files that you need to access from another separate repository while keeping the two projects separate.
- What are Git submodules?
- TL;DR Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.
- In some cases, submodules might not be the right choice for you. In this case, you can clone another Git repository to your Valohai execution inside an execution.
Add a submodule to your Git repository
Make sure the URL of the submodule is in the following format git@mygitprovider.com:<username>/<repository>.git
Valohai won’t be able to fetch a private submodule using the HTTPS address.
You can add a new submodule with git submodule add.
git submodule add git@mygitprovider.com:<username>/<repository>.git
git add .
git commit -m "Added submodule"
git push
Configure access for Valohai
You’ll need to provide Valohai access to both the main repository and all the submodule repositories.
You can provide only one SSH key in the Valohai project’s settings. Make sure this key has access to all the required repositories.
GitHub
When using repositories that don’t have a submodule you can generate a deploy key and add it to your Valohai project.
GitHub allows a deploy key to be used only in one project at a time. This means that you can’t use the same deploy key in your main repository and in your submodule repositories.
To allow Valohai to fetch a repository with submodules you’ll need to:
- Generate and add a new SSH key to your GitHub profile
- Go to your Valohai project settings link the main repository using the generated SSH Key.
You can now fetch the repository and its submodules on Valohai.
GitLab
GitLab allows you to generate a deploy key and use it across multiple repositories.
- If you haven’t already, follow the Integrating with GitLab guide to create a deploy key for your main repository
- On Gitlab open the repository of the submodules project
- Open Project -> Settings -> Repository -> Deploy keys
- Open the Privately accessible deploy keys tab
- Enable the key you’re using in your main repository
You can now fetch the repository and its submodules on Valohai.
Bitbucket
- If you haven’t already, follow the Integrating with Bitbucket guide to create a deploy key for your main repository
- Add the same deploy key to the other repository that you’re using as a submodule
You can now fetch the repository and its submodules on Valohai.
Comments
0 comments
Please sign in to leave a comment.