Loading...

Pulling private repos as git submodules in Code Studio

In certain cases, you might need to pull a git submodule from a private repository into your Code Studio project.

This tutorial demonstrates how to authenticate with a private GitHub repository and pull the git submodule into your Build Code job.

Generating a GitHub personal access token

  1. Log in to GitHub.
  2. Go to Settings > Developer settings > Personal access tokens > Tokens (classic).
  3. Select Generate new token > Generate new token (classic).
  4. Select an expiration period.
  5. In Select scopes, select all items under repo.

  6. Select Generate token and copy the token.

Adding GitHub authentication to the Build Code job

To authenticate with GitHub, use before_script to hook into the Build Code job. To use before_script, you require a custom gitlab-ci.yml file.

  1. Add the GITHUB_TOKEN environment variable to Code Studio and set its value to the token that you copied from GitHub.

    For more information, see Adding environment variables.

  2. Add a before_script to the Build Code job in your project’s gitlab-ci.yml file:

    "Build Code":
              before_script:
                - |
                  # Manually trigger the submodule update
                  git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf [email protected]:
                  git submodule update --init --recursive

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation