Pull code from a private Git repository
Back to home
On this page
To complete its build, your Upsun project may need to access pieces of code stored in private Git repositories. Examples include themes, libraries, and modules. Configure these repositories to grant access to your project.
To grant access to a private Git repository, add the project’s public SSH key to your Git repository’s deploy keys.
1. Get your project’s public key
- In the Console, open the project you want.
- Click Settings.
- Under Project settings, click Deploy key.
- Click Copy.
2. Add the key to your repository in your Git provider
If you’re only pulling code, the key doesn’t need write permissions.
Now your Upsun project can access your private repository via SSH, including to add dependencies.
This means you can access the private repository through links like:
git@GIT_PROVIDER:PATH_OR_USERNAME/REPOSITORY.git
.
For example, you can clone a repository in your build
hook:
applications:
APP_NAME:
hooks:
build: |
set -e
git clone git@bitbucket.org:username/module.git
You can also use private repositories as submodules.
Using multiple private GitHub repositories
GitHub requires a separate deploy key for each repository. To grant your project access to multiple repositories, create an automated user account, known as a machine user, with its own SSH key.
You can then add the machine account as collaborator to specific repositories or to a team with access to the repositories.
See more information about machine users on GitHub.