Chalk’s GitHub integration lets dashboard users install a GitHub App into their GitHub organization, connect Chalk projects to GitHub repositories, and import repository contents into volumes. The integration is powered by a GitHub App whose credentials are held by the metadata plane (the Chalk API server).

In Chalk Cloud, Chalk operates this app for you. When you self-host the metadata plane, you must register your own GitHub App and configure your API server with its credentials. This page walks metadata-plane administrators through that setup.


How the integration works

The API server authenticates to GitHub as a GitHub App:

  1. It signs a short-lived JWT with the app’s private key.
  2. It exchanges that JWT for installation access tokens, scoped to the GitHub organizations (or user accounts) that installed the app.
  3. Installation tokens are used to list repositories and branches, validate project↔repository connections, and download repository archives for volume imports.

No user-level OAuth is involved, and GitHub credentials are never sent to the browser: the dashboard talks only to the API server, which proxies all GitHub API access.


Step 1: Register a GitHub App

Create a new GitHub App at https://github.com/organizations/<your-org>/settings/apps/new (or Settings → Developer settings → GitHub Apps → New GitHub App for a personal account). Configure it as follows:

SettingValue
GitHub App nameAnything you like, e.g. Acme Chalk. The URL slug GitHub derives from it is used below.
Homepage URLYour dashboard URL, e.g. https://chalk.acme.com
Setup URLhttps://<your-dashboard-host>/github-redirect
Redirect on updateEnabled
WebhookDisabled (the integration does not consume webhooks)
Where can this App be installed?“Only on this account” is sufficient if all of your GitHub repositories live in one organization

The Setup URL is required: after a user installs the app, GitHub redirects their browser there with an installation_id, and that page records the installation with the API server. If it is missing or points at the wrong host, installs will succeed on GitHub but never appear in Chalk.

Repository permissions

Grant the following repository permissions. All are read-only:

PermissionAccessUsed for
MetadataRead-onlyListing the repositories an installation can access
ContentsRead-onlyListing branches and downloading repository archives for volume imports
Pull requestsRead-onlyListing pull requests

No account permissions or event subscriptions are needed.

Generate a private key

After creating the app, scroll to Private keys and click Generate a private key. GitHub downloads a .pem file.

Keep the key in the format GitHub provides: an RSA (PKCS#1) PEM beginning with -----BEGIN RSA PRIVATE KEY-----. Do not convert it to PKCS#8 (-----BEGIN PRIVATE KEY-----); the API server only accepts the PKCS#1 format.

Note down from the app’s settings page:

  • App ID (a number, shown under “About”)
  • Client ID (e.g. Iv23...)
  • The app slug — the final path segment of the app’s public page, https://github.com/apps/<slug>

Step 2: Configure the API server

Provide the app’s identity to the API server through environment variables:

Environment variableRequiredDescription
CHALK_GITHUB_APP_IDYesThe numeric App ID
CHALK_GITHUB_APP_SLUGYesThe app’s URL slug; the dashboard’s “Install GitHub App” button links to https://github.com/apps/<slug>/installations/new
CHALK_GITHUB_APP_PRIVATE_KEYYesThe full PEM contents of the private key, including the BEGIN/END lines
CHALK_GITHUB_APP_CLIENT_IDNoThe app’s client ID
CHALK_GITHUB_APP_CLIENT_SECRETNoReserved for future use; not currently required

All three required variables must be set together: if only some are present, the API server logs an error at startup and disables the integration (teams with their own explicit configuration are unaffected).

If the API server runs on Kubernetes, the typical pattern is to add the variables to the secret that already backs the API server’s environment:

kubectl -n <api-server-namespace> patch secret <api-server-env-secret> \
  --type merge \
  -p "$(jq -n --rawfile key chalk-app.private-key.pem '{stringData: {
    CHALK_GITHUB_APP_ID: "123456",
    CHALK_GITHUB_APP_SLUG: "acme-chalk",
    CHALK_GITHUB_APP_CLIENT_ID: "Iv23xxxxxxxxxxxxxxxx",
    CHALK_GITHUB_APP_PRIVATE_KEY: $key
  }}')"

Then restart the API server pods so they pick up the new environment. On a successful boot, the API server logs:

githubapp: default GitHub App enabled from environment

This environment-provided app acts as the default for every team on the metadata plane. A team can override it with its own GitHub App through the GitHubAppService/UpsertGitHubAppConfig RPC; an explicit per-team configuration always takes precedence over the environment default.


Step 3: Verify

  1. In the dashboard, open Settings → Team → GitHub. The app card should show your app’s slug and App ID instead of a “not configured” notice.
  2. Click Install GitHub App. You should land on https://github.com/apps/<slug>/installations/new; pick an organization and confirm.
  3. GitHub redirects back to /github-redirect on your dashboard, which records the installation and links back to the settings page. The new installation appears in the Installations list.
  4. Connect a project to a repository under Connected projects, or use Import from GitHub on a volume page to clone a repository into a volume.

Troubleshooting

SymptomLikely cause
failed_precondition: GitHub App not configured for this teamThe CHALK_GITHUB_APP_* variables are not visible to the API server process (not set, set on the wrong deployment, or the pods were not restarted after the change), and the team has no explicit configuration.
githubapp: ignoring invalid default GitHub App env configuration in API server logsThe variables are partially set, or CHALK_GITHUB_APP_ID is not a number. Set all of CHALK_GITHUB_APP_ID, CHALK_GITHUB_APP_SLUG, and CHALK_GITHUB_APP_PRIVATE_KEY.
Install completes on GitHub but never appears in the dashboardThe app’s Setup URL does not point at https://<your-dashboard-host>/github-redirect, or the installing user’s browser could not reach the dashboard afterwards. Use Sync from GitHub on the settings page to reconcile.
Errors mentioning the private key when listing repositories or completing an installationThe key was converted to PKCS#8. Re-download the key from GitHub (it must begin with -----BEGIN RSA PRIVATE KEY-----), or rotate it and configure the new one.
Repository missing from the pickerThe installation only grants access to selected repositories. Update the repository selection for the installation on GitHub, then Sync from GitHub.

Key rotation

To rotate the app’s private key:

  1. Generate a new private key on the GitHub App settings page.
  2. Update CHALK_GITHUB_APP_PRIVATE_KEY wherever the API server’s environment is managed.
  3. Restart the API server pods.
  4. Delete the old key on GitHub once the restart is complete.

Installation tokens are short-lived and re-minted on demand, so no other state needs to change.