Working with Git Submodules

How to use Git Submodules on Qovery

Some applications use Git Submodules to resolve their dependencies. Git submodules are a feature of the Git SCM that allow you to include the files of one Git repository into another. This short guide will explain how to use Git Submodules on Qovery.

Example

To include the Foo source code into the Bar project, use the following commands:

$ cd ~/code/Bar
$ git submodule add https://github.com/myusername/Foo somefolder/Foo
Cloning into 'somefolder/Foo'...
remote: Counting objects: 26, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 26 (delta 8), reused 19 (delta 5)
Unpacking objects: 100% (26/26), done.

This would create a new submodule called Foo and place Foo code into somefolder/Foo directory of Bar app.

After a Git Submodule is added locally, you need to commit it to your app repository:

$ git commit -am "adding a submodule"
[master 314ef62] adding a submodule
2 files changed, 4 insertions(+)

Committed submodule source code can be used by your application and is available in Qovery CI/CD build/deployment pipeline.

Private Submodules

Qovery does not have access to locally available credentials, so if you want to use some way of authentication, there are two ways to achieve it.

Use HTTP basic authentication URL scheme:

$ git submodule add https://username:[email protected]/myusername/FooBar

This adds a private Git Submodule to the application while still allowing it to resolve in non-local environments.

SSH / Git protocol Submodules

For Qovery to be able to access those private submodules when cloning your application repository, you need to add a secret named GIT_SSH_KEY_xxx, (where xxx can be replaced by anything), containing a private SSH key with access to your Git repository.

SSH:

[submodule "path/to/module"]
url = ssh://user/repo

Git:

[submodule "path/to/module"]
url = git://github.com/torvalds/linux.git