Connect to GitHub Enterprise

This page describes how to create connections to GitHub Enterprise and create links to GitHub Enterprise repositories. You can complete these tasks using the Google Cloud console, or the Google Cloud CLI.

These instructions are for application developers, platform administrators, and security managers who want to use GitHub Enterprise source code repositories with Google. Specifically, you can use GitHub Enterprise repositories with Gemini Code Assist.

To learn more about Developer Connect, see Developer Connect overview.

Limitations

To use connected repositories with Gemini Code Assist, your repositories must be accessible through the public internet.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Developer Connect API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Developer Connect API.

    Enable the API

  8. Enabling Developer Connect also enables the Secret Manager API.

  9. Ensure that you have access to an account on GitHub Enterprise.

    To help keep your team's work secure, we recommend that you complete the tasks in this guide using a bot account or an account shared by your team, not a personal account.

  10. Ensure that you own a GitHub Enterprise repository, or have admin-level permissions on a shared repository.
  11. When using a repository in a GitHub Enterprise organization, ensure that you have GitHub App Manager permissions.

  12. Optional: Create a key a customer-managed encryption key (CMEK) to encrypt your Secret Manager secrets.
  13. Optional: To use the command-line instructions in this guide, complete the following steps:
    1. Install the Google Cloud CLI. If you've installed gcloud CLI previously, make sure you have the latest available version by running gcloud components update.
    2. Create a Developer Connect service account by running the following command, where PROJECT_ID is your Google Cloud project ID:
              gcloud beta services identity create \
                  --service=developerconnect.googleapis.com \
                  --project=PROJECT_ID
              

Grant the required IAM permissions

To get the permissions that you need to create connections and links, ask your administrator to grant you the following IAM roles:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Create a connection

This section describes how to create a connection between Developer Connect and GitHub Enterprise. If you're using the Google Cloud console, then you can also start adding links to repositories as you finish setting up your connection.

To create repository links on an existing GitHub Enterprise connection, select one of the following options:

Console

Initiate a connection by completing the following steps:

  1. In the Google Cloud console, open Developer Connect.

    Go to Developer Connect

    Developer Connect displays the Git repositories page.

    • If you see a list of source code management providers: Start configuring your first connection by selecting a source code management provider. Click Connect on the GitHub Enterprise card.
    • If you see a table listing existing connections: Set the source code management provider by clicking Create connection > GitHub Enterprise.

      The Create Connection page opens.

  2. In the Configure details pane, specify the following:

    1. For Region, choose a region for your connection resources.

    2. For Name, enter a name for your new connection.

    3. For Host URL, enter the URL of the host you want to connect to.

  3. Optional: In the Encryption section, select a CMEK key to encrypt Secret Manager secrets that Developer Connect creates.

  4. Click Continue.

    A GitHub dialog appears, inviting you to create a GitHub app.

  5. Following the prompts in GitHub, complete these tasks:

    1. Input a name for your app.

    2. Choose the organization where you want to install the app.

    3. Select the repositories you want to grant access to.

    The dialog closes.

    Developer Connect fetches your private key from GitHub and stores it in your Google Cloud project as a Secret Manager secret. To view your secrets, list secrets in Secret Manager.

The Link repositories page appears.

  1. In the list of available repositories, select the repositories you want to use.

  2. Click OK.

    Developer Connect displays suggested names for your repository resources.

  3. Select a repository resource naming option:

    • Generated: Use the generated repository resource names.
    • Manual: Input names of your own.
  4. Click Link.

Your connection is added to the Connections page and your repository links are added to the Repositories page in the Google Cloud console. You can add more links to existing connections at any time.

If you're setting up Gemini Code Assist, continue the process by following the steps in Configure and use Gemini Code Assist code customization.

gcloud

The following tasks require some actions in your web browser.

Initiate a connection by completing the following steps:

  1. Run the following command to initiate a connection to GitHub Enterprise:

    gcloud beta developer-connect connections create CONNECTION_NAME \
        --location=REGION \
        --github-enterprise-config-host-uri=HOST_URI
    

    Replace the following:

    • CONNECTION_NAME: the name for your connection.
    • REGION: the region for your connection.
    • HOST_URI: the URI for the host you want to connect to.
  2. You must create a GitHub app to manage connections with GitHub. Run the following command to get URI for app setup:

    gcloud beta developer-connect connections describe CONNECTION_NAME \
        --location=REGION
    

    Replace the following:

    • CONNECTION_NAME: the name for your connection.
    • REGION: the region for your connection.

    Developer Connect returns a link to complete the next steps in a browser window. Copy this link.

  3. Open the link in a web browser.

  4. Sign in to your GitHub account if prompted to do so.

  5. Following the prompts in GitHub, complete these tasks:

    1. Input a name for your app.

    2. Choose the organization where you want to install the app.

    3. Select the repositories you want to grant access to.

    The dialog closes.

    Developer Connect fetches your private key from GitHub and stores it in your Google Cloud project as a Secret Manager secret. To view your secrets, list secrets in Secret Manager.

Verify the connection

Verify the creation of your GitHub connection by running the following command:

gcloud beta developer-connect connections describe CONNECTION_NAME \
    --location=REGION

Where:

  • CONNECTION_NAME: the name of your connection.
  • REGION: the region for your connection.

Developer Connect returns a status in the installationState field. If the value of this field is COMPLETE, your app installation is done. Otherwise, Developer Connect returns a URI to return you to configuration in the browser.

Once your connection is completed, choose which repositories to link by following the instructions in Link to repositories.

Once you have established a connection to GitHub Enterprise, you can link to repositories. You can repeat these steps later to link additional repositories as needed.

To create repository links on an existing GitHub Enterprise connection, select one of the following options:

Console

  1. Open the Repositories page in the Google Cloud console.

    Open the Repositories page

  2. Click Link repository.

    The Link Git repositories pane opens.

  3. In the connections list, choose a connection.

  4. Click Continue.

  5. In the repositories list, select the repositories you want to link to.

    Developer Connect displays suggested names for your repository resources.

  6. Select a repository resource naming option:

    • Generated: Use the generated repository resource names.
    • Manual: Input names of your own.
  7. Click Create.

Developer Connect creates the repository links and displays them in the Google Cloud console.

gcloud

Run the following command:

gcloud beta developer-connect connections git-repository-links create REPO_NAME \
    --clone-uri=REPO_URI \
    --connection=CONNECTION_NAME \
    --location=REGION

Replace the following:

  • REPO_NAME: a name for your repository link.
  • REPO_URI: the link to your repository. For example, https://github.com/cloud-build/test-repo.git.
  • CONNECTION_NAME: the name of your connection.
  • REGION: the region for your connection.

Developer Connect creates the repository links.

To list linked repositories, run the developer-connect connections git-repository-links list command.

If you're setting up Gemini Code Assist, continue the process by following the steps in Configure and use Gemini Code Assist code customization.

Data sharing

Content from Google Cloud resources linked to this connection might be transferred to GitHub. This statement applies to all existing and future resources utilizing this connection. To stop sharing information with GitHub, delete Developer Connect connections in the Google Cloud console or gcloud CLI, and revoke access in GitHub.

What's next