In your Harness project, select Connectors under Project Setup.
Create a new connector or edit an existing GitHub connector.
Configure the GitHub connector settings. The GitHub App is part of the Credentials settings.
For Authentication, select GitHub App.
Enter your GitHub installation ID and app ID.
Select your private key file secret.
Select Continue.
If the connection test succeeds, select Finish to save the connector.
Use a GitHub App in a GitHub connector
Use a GitHub App to authenticate a GitHub connector, instead of a personal access token or OAuth.
You can use a GitHub App to provide authentication for a GitHub connector. This enables API access to GitHub through the GitHub App.
Harness recommends using GitHub Apps for GitHub connectors, because GitHub Apps offer more granular permissions than other authentication methods and increased rate limits.
The following video uses Harness Continuous Delivery to demonstrate the benefits, features, and configuration of GitHub Apps in Harness.
What you will learn from this topic
How to create and register a GitHub App in your GitHub account or organization.
How to install the GitHub App on the repositories you want Harness to access.
How to generate a private key for the app and store it as a Harness secret.
How to configure a GitHub connector to use the GitHub App as its primary authentication method or its API access authentication method.
Before you begin
Before you begin working with GitHub apps, familiarize yourself with the following:
You must also meet one or more of the following permission criteria before you create or install a GitHub App:
You can install GitHub Apps on your personal account or under an organization where you have administrative access.
You have admin permissions on a GitHub repo under a GitHub organization, and you can install GitHub Apps in that repo.
You will install the GitHub App in a repo that requires an organization's permission, and the organization owner has approved the application, and can provide approvals as needed to proceed with app installation.
Create and configure a GitHub App
Perform the following steps to create, install, and configure a GitHub App for your GitHub connector.
Create the GitHub App
You can create and register GitHub Apps in your personal GitHub account or in any GitHub organization where you have administrative access.
Follow the instructions in the GitHub documentation on Creating a GitHub App. Populate the settings as follows:
GitHub App Name: Enter a name.
Homepage URL: Enter
https://harness.io/.Webhook: Deselect Active. The app is used for authentication and does not need to receive webhook events.
Permissions: Configure the following Repository Permissions:
Commit statuses: Select Read & write.
Contents: Select Read & write.
Metadata: Select Read-only.
Pull requests: Select Read & write. This is required for the Issue Comment event trigger for GitHub.
Webhooks: Select Read & write.
Where can this GitHub App be installed: Select Any account. The app must be public to use it with a GitHub connector.
Install the GitHub App
Follow the instructions in the GitHub documentation on Installing your own GitHub App, and note the following:
For Repository access, select Only select repositories, and then select the repos you want to connect with through your Harness GitHub connector.
Configure these Permissions:
Metadata: Read
Code: Read & write
Commit statuses: Read & write
Pull Requests: Read & write
Get the Installation ID and App ID
You need the Installation ID and App ID to configure your Harness GitHub connector.
Get the Installation ID from the URL of the installed app, such as:

GitHub App installation page showing the installation ID in the URL Get the App ID from the app's General tab.

GitHub App General tab showing the App ID
Generate a private key
You need a private key for your GitHub app to configure your Harness GitHub connector.
Follow the instructions in the GitHub documentation for generating private keys for GitHub Apps.
Save the private key file to your local machine. GitHub only stores the public portion of the key.
Open a terminal and
cdto the folder containing the key.Run the following command to convert the key file to the necessary format for the Harness GitHub connector. Replace
YOUR_KEY.pemwith the name of the PEM file you saved:In Harness, store the converted key file as a Harness encrypted file secret.
Configure the GitHub connector
You can use your GitHub App as either the primary authentication method or the API access authentication method for your GitHub connector.
In your Harness project, select Connectors under Project Setup.
Create a new connector or edit an existing GitHub connector.
Configure the GitHub connector settings. The GitHub App is part of the Credentials settings.
Select Enable API access. This setting is only available for connection types and authentication methods where it is not already enabled by default.
For API Authentication, select GitHub App.
Enter your GitHub installation ID and app ID.
Select your private key file secret.
Select Continue.
If the connection test succeeds, select Finish to save the connector.
Set up a PR trigger (optional)
You can configure your pipelines to use Git event triggers so that builds automatically run in response to events in your Git repos.
If you want to set up a PR trigger, make sure the webhook definition uses the Pull Request event.
Next steps
Add a GitHub connector: Configure a GitHub connector that uses this GitHub App for authentication or API access.
GitHub connector settings reference: Review every setting available on the GitHub connector.
Git event triggers: Run pipelines automatically in response to events in your GitHub repos.
Last updated
Was this helpful?