Create the GitHub App

Create the GitHub App of your CIHub instance, give its keys to CIHub, install it on your repositories, and check that GitHub reaches the instance.

Your CIHub instance talks to GitHub through a GitHub App that you own. The App receives the webhooks of your repositories, gives CIHub the rights to test and merge pull requests, and signs people in to the dashboard. You create it once, on GitHub.

Before you start

  • The HTTPS address of your instance, reachable from GitHub, for example https://cihub.example.com. The examples below write it https://<your CIHub host>.
  • Owner rights on the GitHub organization that will own the App.

Create the App

The App has three addresses on your instance. Most mistakes come from mixing them up:

Your GitHub AppCIHubhttps://cihub.example.comWebhook URLthe events of your repositories/webhooks/githubCallback URLa person back from the sign-in/auth/github/callbackSetup URLa person back from an installation/auth/github/installed
Three addresses of the App, three paths of CIHub on the same host. GitHub calls the first one; it sends people to the other two.

Generate the webhook secret first:

openssl rand -hex 32

Open the form

  • For an organization: your profile picture → Your organizations → Settings next to the organization → Developer settings → GitHub Apps → New GitHub App.
  • For a personal account: your profile picture → Settings → Developer settings → GitHub Apps → New GitHub App.

On a GitHub Enterprise Server, the path is the same on your server.

Fill in the identity and the sign-in

FieldValueWhy
GitHub App nameAny free name, for example Acme CIHubIts bot writes the comments and the statuses: acme-cihub[bot]
Homepage URLhttps://<your CIHub host>Shown on the page of the App
Callback URLhttps://<your CIHub host>/auth/github/callbackWhere GitHub sends a person back after the sign-in to the dashboard
Expire user authorization tokensChecked (the default)CIHub refreshes the token of each person
Request user authorization (OAuth) during installationUncheckedChecked, GitHub would skip the Setup URL after an installation
Enable Device FlowUncheckedThe command line cihub signs in through the dashboard, not through GitHub
Setup URLhttps://<your CIHub host>/auth/github/installedAfter an installation, GitHub sends the person to the repositories of the new organization
Redirect on updateCheckedThe same after a change of the repositories of the installation

Fill in the webhook

FieldValue
ActiveChecked
Webhook URLhttps://<your CIHub host>/webhooks/github
Webhook secretThe secret that you generated
SSL verificationEnabled

Set the permissions

Under Repository permissions:

PermissionAccessWhat CIHub does with it
ActionsRead-onlyShow a check of GitHub Actions as running when a runner takes its job
AdministrationRead-onlyRead the rules of the branches, for their required checks and to check your setup
ChecksRead-onlyRead the checks of your CI on the test commits
Commit statusesRead and writeWrite the statuses CIHub Merge Queue (<branch>) and CIHub Conditions (<branch>)
ContentsRead and writeWrite the test branches, merge, read .cihub.yaml
IssuesRead and writeLabels and reactions on the pull requests
MetadataRead-onlyList the repositories (GitHub sets it)
Pull requestsRead and writeRead the pull requests, open and close the draft pull requests of the tests, merge, comment

Under Organization permissions: Members, Read-only, to give each person the role that they have on GitHub.

Leave every other permission at No access.

Subscribe to the events

Under Subscribe to events, check:

  • Branch protection rule
  • Check run
  • Check suite
  • Issue comment
  • Pull request
  • Pull request review
  • Push
  • Repository
  • Status
  • Workflow job

GitHub sends the events of the installation itself without a subscription.

Keep the App private

Under Where can this GitHub App be installed?, choose Only on this account, then Create GitHub App.

Any account that installs your App gets an organization in your CIHub: a public App would let anyone use your instance.

Collect the keys of the App

On the page of the new App (General):

  1. Note the App ID and the Client ID.
  2. Under Client secrets, Generate a new client secret, and copy it: GitHub shows it once.
  3. Under Private keys, Generate a private key: your browser downloads a .pem file.

Keep the private key, the client secret and the webhook secret in your secret store. The private key and the client secret act as the App: whoever has them can act on every repository where the App is installed.

Give the keys to CIHub

You now have five values: the App ID, the private key, the webhook secret, the Client ID and the client secret. Give them to CIHub as Run CIHub with Docker or Run CIHub on Kubernetes shows, then come back here to install the App.

on the page of the Appthe server of CIHubApp IDGeneral, at the topCIHUB_GITHUB_APP_IDClient IDGeneral, at the topCIHUB_GITHUB_CLIENT_IDClient secretGenerate a new client secretCIHUB_GITHUB_CLIENT_SECRETPrivate keyGenerate a private key (.pem)CIHUB_GITHUB_PRIVATE_KEY_FILEWebhook secretopenssl rand -hex 32CIHUB_GITHUB_WEBHOOK_SECRET
You copy five values from the page of the App to the server.
ValueVariable of the server
App IDCIHUB_GITHUB_APP_ID
Private keyCIHUB_GITHUB_PRIVATE_KEY_FILE (a path), or CIHUB_GITHUB_PRIVATE_KEY (the PEM)
Webhook secretCIHUB_GITHUB_WEBHOOK_SECRET
Client IDCIHUB_GITHUB_CLIENT_ID
Client secretCIHUB_GITHUB_CLIENT_SECRET
GitHub Enterprise ServerCIHUB_GITHUB_URL

The Client ID and the client secret turn on the sign-in to the dashboard, with the public address (CIHUB_HTTP_PUBLIC_URL) and a sealing key (CIHUB_DATABASE_SECRET, at least 32 bytes, which seals the GitHub tokens of the people who sign in). Without them, only the API tokens work. cihub-server start stops at startup and names the value that is missing.

Install the App on your repositories

On the page of the App: Install App → your organization → Only select repositories (or All repositories) → Install.

GitHub then sends you to the Setup URL: sign in to the dashboard, and it opens the repositories of the new organization. You create nothing else: CIHub creates the organization, named after the login of the account, and the first /cihub merge on a branch creates its queue. To add or remove repositories later, change the installation on GitHub (Settings → GitHub Apps → Configure in the organization); CIHub reads the change.

Check that GitHub reaches CIHub

  1. On the page of the App: Advanced → Recent Deliveries. The installation delivery has a green mark: CIHub answered it.
  2. The dashboard lists the repositories that you selected.
  3. A comment /cihub merge on an approved, green pull request gets a 👍 reaction, then the comment of CIHub.
SymptomCauseFix
The deliveries fail with a timeout or a connection errorGitHub cannot reach the instanceCheck the DNS, the TLS certificate and the route to /webhooks/github from outside your network
The deliveries fail with an error status from CIHubThe webhook secret differs between the App and CIHubSet the same secret in both, then Redeliver the failed deliveries
The sign-in comes back to the sign-in page with an errorCallback URL, client ID, client secret or public addressCompare the Callback URL with <public address>/auth/github/callback, and the client keys with the App
After the installation, GitHub does not open the dashboardThe Setup URL is empty, or the OAuth box is checkedSet the Setup URL, uncheck Request user authorization (OAuth) during installation
Nothing happens on the pull requests of a repositoryThe repository is not in the installationAdd it to the installation of the App

Change the permissions later

When a new version of CIHub needs a new permission or event, change it on the page of the App. GitHub then asks an owner of each organization to accept the new permissions (Settings → GitHub Apps in the organization): until they do, the installation keeps the old ones.

From the release after 0.3.0, the App needs Actions, Read-only, and the Workflow job event: without them, a check of GitHub Actions shows queued until it ends, never running. On an older App, add them on the page of the App, then accept them in each organization.

On this page

For agentsThis page as Markdown:/docs/install/github-app.md