Platform.sh User Documentation

Pull code from a private Git repository

Try for 30 days
Flexible, version-controlled infrastructure provisioning and development-to-production workflows
Activate your trial

To complete its build, your Platform.sh 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 Anchor to this heading

  1. In the Console, open the project you want.
  2. Click Settings.
  3. Under Project settings, click Deploy key.
  4. Click Copy.

Deploy Key

2. Add the key to your repository in your Git provider Anchor to this heading

If you’re only pulling code, the key doesn’t need write permissions.

Now your Platform.sh 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:

.platform.app.yaml
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 Anchor to this heading

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.

Is this page helpful?