Skip to main content
GitHubGitLabBitbucketGitea
Connect a git provider once for the whole control plane, then point any number of apps at repositories it can see. A push, a tag, or a pull request on the repository then deploys the app, builds a preview, or both. No provider at all? A git push remote on your own server (beta) deploys a pushed branch with no webhook. This page covers connecting a provider, using a repository as an app’s source, deploy triggers and path filters, deploying a commit by hand, monorepo build settings, webhook handling and replay, and per-pull-request previews.
Fastest path: connect the provider in the dashboard (Connect a provider), then run levelrail-cli github-app use-as-source <owner> <repo> --app-name my-app. Pushes to the default branch deploy from then on.

SSH deploy key for private repositories

A private repository on any git host can be cloned over SSH with a per-app deploy key, with no personal access token. Set the git source’s repo_url to an SSH URL (git@host:owner/repo.git or ssh://git@host:port/owner/repo.git), then mint the key.
The output holds public_key (an ed25519 key in authorized_keys format), its fingerprint, and the pinned host_fingerprint. Add the public key to the repository’s deploy keys (read-only is enough). ssh-key show my-app prints the same fields later and ssh-key delete my-app removes the key. generate (alias rotate) always mints a new key, so it also rotates. The same operations are available as GET, POST and DELETE on /api/v1/apps/my-app/git-source/ssh-key and in the app’s git source settings in the dashboard. To create an app straight from an SSH repository, run apps create --repo ssh://git@host/owner/repo.git .... The app and its git source are created first; the build waits until the key exists, and the command prints the ssh-key generate step to run, then apps git-source deploy.
  • The private key is generated on the control plane, stored encrypted with the same envelope encryption as every secret, and never returned by any route or written to a log. Clones hold it in memory only, so no key file touches disk and no shell command is built from user input.
  • Host keys are always pinned. Pass --host-key FILE (host_key in the API; the server’s public key in authorized_keys format, for example from ssh-keyscan) to pin one you verified yourself, or --trust-on-first-use to scan once and pin what the host presents; compare the returned host_fingerprint with the host’s published fingerprint. A later clone that sees a different host key fails. There is no option to skip host key checking.
  • An SSH repository with no stored deploy key is refused before any connection. The control plane never falls back to its own ssh-agent or known_hosts.
  • Trust-on-first-use scans refuse loopback, private and link-local addresses, so a git URL cannot be used to probe your internal network. For a self-hosted git server on a private range, either paste its host_key or list its IP or CIDR in the git.ssh_scan_allow_internal runtime setting. Cloud metadata addresses are never allowed.
  • Keys are per app, so one compromised key exposes only that app’s repository. The scan timeout comes from APP_GIT_SSH_SCAN_TIMEOUT (default 10s).
Webhook registration, branch listing and build detection still use the provider API, so an SSH-only source deploys from pushes you wire to the app’s webhook URL by hand, or from a manual deploy.

Provider connections and git sources

Two records are involved, and keeping them separate is deliberate.
  • A provider connection (a GitHub App installation, or a GitLab, Bitbucket or Gitea account authorized through an OAuth application) is a control-plane-wide credential that can see many repositories across many organizations or workspaces. You can connect several of each kind: see Connecting more than one account.
  • An app’s git source (GET/PUT/DELETE /api/v1/apps/{name}/git-source) is a per-app record: one repository URL, one branch, one build configuration, one webhook secret, and one deploy trigger mode. Each app has its own webhook secret and its own enable and disable state.
So you connect GitHub once, wire ten apps to ten different repositories, and never paste a personal token into an app by hand.

Provider differences

All four support webhooks, preview environments, and PR comments and commit statuses. GitHub’s manifest flow creates the App on GitHub’s side for you. GitLab, Bitbucket, and Gitea need you to create the application in their own settings first and paste its credentials in. GET /api/v1/git-providers (and levelrail-cli git-providers) answers “what can I do with each provider?” in one call: whether it is connected, can list branches, can register a webhook, and can authenticate a clone. The dashboard’s repository picker uses it.

Connect a provider

Connecting is done in the dashboard on purpose. Each flow ends in a real browser redirect to github.com, your GitLab instance, or bitbucket.org, which a script or the CLI cannot drive. The CLI can register, rename, list and disconnect accounts, and print the authorize path to open in a browser.
All four need a master key configured on the control plane, the same one that encrypts every secret. Routes that need it return 501 without one. GitHub’s manifest flow also needs a primary domain set in ingress settings first, because GitHub needs a reachable callback URL. Without one you get a 409 that says so.
Open the GitHub App settings page (/settings/github-app).
1

Choose the owner

The dashboard previews the App’s name, permissions, and webhook URL and lets you choose who owns the App.“Allow other accounts and organizations to install it” makes the App public (public=true). Leave it off for a private App, which GitHub only lets the owning account or organization install.
2

Create the App on GitHub

The dashboard redirects your browser to github.com, and the credentials come back automatically. levelrail-cli github-app register-url --owner <org> [--public] prints the registration link for the same choice. Open it in a browser signed in to the dashboard.
3

Install it

Levelrail sends you to /apps/<slug>/installations/new, GitHub’s account chooser. Pick the account or organization and the repositories to grant. You need to be an owner of the organization, or its owners must approve the install request. Use “Add organization” in the connected accounts list to install the same App on another account later.
A private App owned by your personal account never offers an organization on the install page. To deploy from an organization, either own the App from that organization or make the App public. Levelrail asks GitHub whether the App is public; when it is private, the dashboard and github-app installations add say so and link to the App’s Advanced settings, where “Make public” allows installs on any account.
GitHub Enterprise Server works the same way: set instance_url and the form posts to <instance_url>/organizations/<login>/settings/apps/new. owner must be a GitHub organization login (letters, digits and hyphens, up to 39 characters); anything else is a 400.If the control plane has no publicly reachable primary domain yet, create the App at github.com/settings/apps yourself and connect it with PUT /api/v1/github-app/manual, giving the app ID, client ID, client secret, webhook secret, and the private key PEM.
To disconnect GitHub, call DELETE /api/v1/github-app. To disconnect one GitLab, Bitbucket or Gitea account, call DELETE /api/v1/git-connections/{id} (or press Disconnect on its row). Either removes the connection and its secrets from the control plane, revokes the OAuth token at GitLab, and answers {disconnected, token_revoked, note, affected_sources}. It does not uninstall the GitHub App or delete the application on the provider’s side; the note says where to do that. Other connected accounts are not touched.

Connect with a token instead

GitLab, Bitbucket Cloud, Gitea and Forgejo can also connect with an access token, with no OAuth application and no public domain, so it works on a plain http:// install. In the dashboard choose Add account, then Connect with a token, or press it on a provider’s settings page. The panel shows where to create the token and which scopes to tick: Check Token asks the host for the account, the scopes (GitLab reports them) and how many repositories the token reaches before anything is saved. Connecting stores the token encrypted and the account shows up like any other, with health. From the CLI: git-providers test --type gitlab --instance-url URL --pat TOKEN, then git-providers add with the same flags. A self-hosted server on a private network needs APP_GIT_ALLOW_PRIVATE_NETWORKS=true on the control plane. Tokens do not refresh: when one expires or is revoked the account shows Needs reconnect, and you add a new token.

Connecting more than one account

The quickest way to see and manage every account is the Git connections page (Settings, Git connections, /settings/git-connections). It lists each GitHub, GitLab, Bitbucket, Bitbucket Server, Gitea and Forgejo (including Codeberg) account in one place with its health, repository count and the apps using it. Its Add account menu starts the connect flow for any host and, where the host needs one, asks for a primary domain first. In the repository picker, when more than one account is connected, account chips filter the list and the last choice is remembered per user. GitHub supports many installations. GitLab, Bitbucket and Gitea support many accounts too: a personal and a work Bitbucket workspace, several GitLab groups or accounts, gitlab.com next to a self-managed GitLab, or two Gitea servers. Each one is a connection with its own label, host, signed-in account, scopes and health. To add another account:
  1. Open the provider’s settings page (/settings/gitlab-app, /settings/bitbucket-app or /settings/gitea-app) and press Add another account.
  2. To sign in with a different account on an instance you already use, choose Reuse the application of …. Nothing else to enter. To use another instance or another OAuth application, choose Register a new OAuth application and paste its instance_url (GitLab, Gitea), client ID and secret. Optionally give it a label.
  3. Press Save and authorize. You are sent to the provider to approve; you come back to the settings page with the new account listed.
From the CLI, levelrail-cli git-providers add gitlab --instance-url https://git.example.com --client-id ID --client-secret SECRET registers the application and prints the authorize path to open in a browser. --reuse <connection id> copies another connection’s application. Forgejo (including Codeberg) connects exactly like Gitea, under its own provider. Bitbucket Server and Data Center connect with a personal access token instead of an OAuth application: levelrail-cli git-providers add bitbucket_server --instance-url https://bitbucket.example.com --pat TOKEN verifies the token and connects at once. Repositories there are addressed as PROJECT/slug, and the webhook it registers delivers repo:refs_changed pushes (pull request previews are not supported on Bitbucket Server yet). How it behaves:
  • Connecting again with a different account adds a connection and never replaces another. Connecting again with the same account (same host, same remote account, same OAuth application) updates that connection’s tokens instead of adding a duplicate. The same login through a different OAuth application is a separate connection, which is what a Bitbucket workspace consumer needs.
  • The label defaults to account @ host once the account is known. Rename it any time.
  • The first connection of a provider is its default. Set another with Set default or levelrail-cli git-providers default <id>. The default is used when a request does not name a connection.
  • Reconnect on a row sends that connection through authorization again, for example after its grant was revoked.
  • Disconnect removes only that connection. Git sources that used it stay, show needs reconnect, and are never deleted. They attach to the next connection you add on the same host.
  • Connections belong to the control plane and are created, renamed and removed by an admin (the root ability). Anyone with the read:sensitive ability can list them (no credentials are ever returned) and browse the repositories an account can see, as with the GitHub App.
  • Existing GitLab, Bitbucket and Gitea connections from before this change became the first connection of their provider on upgrade, with their tokens and git sources intact. The account name fills in the first time the connection is used.
Pick the account when you choose a repository: the picker shows every connected account, filters by account, and shows the owner and account on each row, so acme/api from your work account and acme/api from your personal one are never confused. The git source records the account it came from, and its webhook is registered with that account’s token.

Listing repositories

The repository picker, GET /api/v1/git/repos and levelrail-cli git-providers repos <provider> all read one cached list per connection. Nothing is cut off at a fixed page count: the control plane pages through the provider until it runs out, up to APP_GIT_REPO_LIST_MAX repositories per connection (default 10000). If an account has more than that, the response says truncated: true and the picker says so; paste a repository URL for one beyond the cap. Search, owner, archived and fork filters and paging are applied on the server, so a large account never reaches the browser in one response. A list is served from the cache for APP_GIT_REPO_CACHE_TTL (default 5m). After that it is still served for up to APP_GIT_REPO_CACHE_STALE_MAX (default 24h) while one background refresh runs, and concurrent requests share a single provider call. GitHub pages are revalidated with ETags, so an unchanged page costs no rate limit budget. Disconnecting a provider, changing its connection or removing a GitHub installation drops its cached list. The dashboard picker has a Refresh button; the CLI has --refresh. When a provider answers 429 or a secondary rate limit, the control plane waits for a short Retry-After (at most APP_GIT_RATE_LIMIT_MAX_WAIT, default 5s, up to APP_GIT_RATE_LIMIT_RETRIES times, default 2). A longer wait is not slept on: a saved list is served with a rate_limit.next_check_at notice, or, with nothing saved yet, the call returns 429 with a Retry-After header and the next check time. APP_GIT_RATE_LIMIT_BACKOFF (default 60s) is the assumed wait when the provider sends no Retry-After.

What a connection can do

GET /api/v1/git-connections/{id}/access shows what a connection’s credential allows, so a missing scope is visible before a feature fails. It needs the read ability and never returns a token or secret. The answer holds the provider, auth_method (oauth_app or token), the granted scopes with scopes_known and scopes_source, expires_at and last_used_at when the provider reports them, and visible_accounts (a bounded list of group or account names with a total). A capabilities list covers list_repos, clone_sync, register_webhook, tag_push_trigger, commit_status, mr_comments, deployments_report, registry_pull and import_group. Each has a state of allowed, not_allowed or needs_scope, the needs_scope that would fix it, and verified, which is true only when the state follows from scopes the provider itself reported. GitLab reports scopes, so a token with only read_api shows webhooks, commit statuses and comments as needs_scope: api. Bitbucket does not report scopes, so it answers scopes_known: false and inferred states. Gitea and Forgejo report no scopes either, so their capabilities come from the repository permissions the server reports for the repositories the token can reach: webhooks need admin on a repository, commit statuses and comments need write. expires_at shows the expiry of an OAuth token; a personal token on these servers does not expire. If the provider cannot be reached the call still returns 200 with the stored facts and a live_check_error. Live results are reused for git.access_cache_ttl_seconds (env APP_GIT_ACCESS_CACHE_TTL_SECONDS, default 60) and the name list is capped by git.access_names_max.

Gitea and Forgejo checks

The Gitea and Forgejo clients are exercised against throwaway local containers of the official images, started on random loopback ports with no volumes. The run covers OAuth application creation by API, the authorization code flow with PKCE and token refresh, repository listing by owner and organization, an idempotent webhook with a signed delivery for a test event, a push and a pull request, commit statuses, one updated pull request comment, and changed file lists. Run it with scripts/qa/forge-gitea.sh. It needs Docker, pulls two small images, removes the containers when done and the images unless KEEP_IMAGES=1. The webhook secret is verified from the X-Gitea-Signature header (hex HMAC-SHA256 of the body), which both servers send.

Credential health, auto-renew and rotation

Each connection says what kind of credential it holds. credential_kind is oauth_auto_renew when a refresh token is stored, and static_token for a pasted token. The connection also reports auto_renew, expires_at, last_refresh_at, last_refresh_error and can_rotate. None of these carry a secret. An OAuth connection renews itself. A background check runs every git.oauth_refresh_interval (env APP_GIT_OAUTH_REFRESH_INTERVAL, default 1m) and refreshes any access token that expires within git.oauth_refresh_lead (default 10m). A refresh that works is silent. A grant the provider rejects raises an alert at once; a provider that is only unreachable raises one after git.oauth_refresh_failure_grace (default 30m). The alert is one Status row (git_connection_reauth, with a Re-authorize link) and one git_connections.reauth_needed event, and both clear when a refresh works again. Connections that already need a new authorization are skipped, not retried. Turn the whole loop off with git.oauth_refresh_enabled (env APP_GIT_OAUTH_REFRESH_ENABLED); tokens are then refreshed only when a request needs them, and the System Doctor row git_oauth_refresh warns while it is off. A pasted token cannot renew itself. When the host reports an expiry (GitLab does), the control plane sends one git_connections.expiring event per window in credential_expiry.reminder_windows_days and shows a git_token_expiring row on Status inside the widest window. The event carries the connection, the expiry and the rotate path, never the token. POST /api/v1/git-connections/{id}/rotate replaces a pasted GitLab personal access token through GitLab’s own rotation call. It needs the root ability, is audited as git_connection.rotated, and the token needs the self_rotate scope. The body is optional: {"expires_at": "YYYY-MM-DD"}, otherwise the new token lasts git.rotate_lifetime_days (default 90). GitLab revokes the old token at once. The answer is {"rotated": true, "expires_at": "...", "connection": {...}} and never contains the new secret. It answers 409 for an OAuth connection, a connection that is not authorized, a provider that cannot rotate, or a token without the scope.

Reconnecting a provider

Each connection has a health state, shown on its settings page, in GET /api/v1/git-providers (connection.status), in levelrail-cli git-providers and in the System Doctor check git_connections. API calls that hit a needs_reauthorize or revoked connection answer 409 with {"code": "needs_reauthorize"} (or revoked) instead of an internal error. A rate limit answers 429 with Retry-After. The status clears itself on the next call the provider accepts. GitLab, Bitbucket and Gitea refresh their OAuth tokens one caller at a time per connection. A caller that waited reuses the token another caller just refreshed, and a refresh token is never spent twice, so concurrent requests cannot break a provider that rotates refresh tokens. Disconnecting a provider reports what happened on the provider’s side: GitLab’s token is revoked at GitLab; GitHub (installation tokens are minted per call and never stored), Bitbucket and Gitea have nothing the control plane can revoke, and the response says where to remove the grant by hand. GitLab asks for the broad api OAuth scope, because it is the one scope that covers listing projects and registering webhooks. It grants read and write on everything the connecting account can see. Connect with a dedicated, least-privileged GitLab account or a bot user if that is too wide.

Use a repository as an app’s source

Once a provider is connected, the CLI can list repositories and branches and connect a repository to an app. use-as-source also registers the webhook in the same call.
use-as-source takes the same optional settings as PUT /api/v1/apps/{name}/git-source:
If webhook registration fails, GitHub and GitLab still connect the repository and report webhook_registered: false with a webhook_error and the webhook secret, so you can add the hook by hand (for GitHub, typically an installation that predates the repository_hooks:write permission). Bitbucket and Gitea fail the whole request with a 502 instead. The hook GitLab registers subscribes to push, tag push and merge request events, so release trigger mode works from an auto-registered hook. For an app that already exists, levelrail-cli apps git-source get|set|delete <name> manages the git source directly.

Validate access

The git source card has a Validate access button (CLI: levelrail-cli apps git-source validate <name>). It reads the app’s branch with the credential a deploy would use (a stored deploy token, else the connected GitHub App) and reports a typed fix: no credential for a private repo, a rejected or expired token, a token that cannot see the repository, a missing branch, or an unreachable host. Each provider settings page has the same button for the connection itself (levelrail-cli git-providers validate <provider>). Installation tokens minted from the GitHub App are registered with the secret masker, so they never appear in logs or stored output.

Deploy triggers: push or release

Every git source has a trigger_mode. It is independent of preview environments and is not part of app.yaml. Switching modes takes effect on the next webhook and never touches what is currently deployed. Set it from the Deploy trigger select on the app’s git source card, or from the CLI:
How each provider handles release mode:

Path filters

A git source can deploy only when a push changes files you ship:
--paths and --paths-ignore take comma-separated doublestar globs (** spans directories, dotfiles match, commas inside {a,b} do not split) and replace the whole list. An empty value clears it. Tag pushes are never path filtered. A push whose changed files all fall outside the filter is answered with ignored: skipped: no changed path matched paths (or ... matched paths_ignore) and shows in the delivery history. The file list comes from the push payload. When the payload has none (Bitbucket, or a push of more than 20 commits) the control plane reads it from the provider, and if that fails the push deploys anyway. The dashboard has the same fields on the app’s Source tab under Deploy filters and status reporting.

Reporting back to the provider

With report_status on (the default), the control plane reports to the provider:
  • Pipeline runs get a commit status per run, linking to the run page. See Pipelines.
  • GitHub deploys get a Deployments API entry for each push deploy (environment production) and each pull request preview (environment preview), moving through in_progress to success or failure. A newer successful deploy marks earlier ones in the same environment inactive, a partially failed multi-service deploy is failure, a superseded deploy is inactive, and closing a pull request marks its preview deployment inactive. A deployment the provider refuses to create is kept as an error row with the reason.
GitHub Apps registered recently request statuses: write and deployments: write. An App registered earlier needs those permissions added and accepted in GitHub, otherwise posts fail with a warning and nothing else changes. A failed post never fails a deploy or run. Turn reporting off for one app with levelrail-cli apps git-source settings my-app --report-status=false, or for the whole server with APP_GIT_STATUS_ENABLED=false. GitHub merge_group events route to pipelines with a merge_group trigger; subscribe the repository webhook to the “Merge groups” event.

Deploying by hand

A push deploys on its own, but you can also deploy any commit yourself. The Deploy button on an app opens a sheet that adapts to what the app deploys from.
Git source connected. The sheet leads with “Deploy latest commit on <branch>”: the head commit’s SHA, message, author and age, with a one-click Deploy latest commit button.
  • Below it are the ten most recent commits, each with its own Deploy and a badge for live, failed or building.
  • A branch switcher and the build it will run (build pack, Dockerfile path, build directory) follow.
  • A status line says whether what is live is up to date or how many commits behind the head it is.
  • Redeploy last successful and Roll back to previous appear once the app has history.
  • After you click Deploy the sheet closes and opens the live build log.
Image only. An image form pre-filled with the current image and your recent tags as one-click chips. The “fresh registry lookup” option lives under Advanced.Nothing connected. A guided choice between connecting a repository and deploying an image.
Deploying a different branch than the connected one builds that branch once. Push webhooks keep following the connected branch.

Suggestions

The sheet also lists suggestions computed on the control plane, each with a reason and one click to act. You can dismiss any of them; dismissals are remembered in your browser only. Not sure what a repository will be detected as? Import a repository explains the detection and how to preview it with apps analyze.

Monorepos and build settings

A git source builds from two settings, and both are relative to the repository root:
  • Base directory is the Docker build context. Empty means the repository root.
  • Dockerfile path is the Dockerfile to build, for example apps/web/Dockerfile. It is relative to the repository root, not to the base directory, and it must sit inside the base directory when one is set. Empty uses Dockerfile in the build context.
Auto-detect (Railpack) only looks at the base directory, so a monorepo with no app at its root needs one of the two settings above. The Source tab states the resolved result in plain words (“Builds apps/glinr/deploy/Dockerfile with the repository root as the build context”), and the CLI prints the same sentence.

Finding the right settings

Detection lists Dockerfiles and build roots from the provider’s file-tree API without cloning the repository (GitHub, GitLab and Gitea; other hosts use a shallow in-memory clone). It ignores node_modules, vendor, dist and similar folders, and reads turbo.json, pnpm-workspace.yaml, nx.json, go.work, Cargo and npm workspaces and compose files to explain what it found.
In the dashboard, the Source tab shows the same list under “Detected in this repo”, with a one-click “Use this” on each suggestion. When an app uses auto-detect on a repository with no app at its root, the tab shows a “This looks like a monorepo. Pick a Dockerfile.” notice, and a failed build links to it. Apply the recommended suggestion straight from the CLI with levelrail-cli apps git-source detect <name> --apply. Invalid values (absolute paths, .., or a Dockerfile outside the base directory) are rejected with a 400. See Monorepos for workspace packages, per-service watch paths and affected-only deploys.

The turbo prune pattern

A Dockerfile that runs turbo prune needs the whole repository as its context, because the prune step reads the root turbo.json and lockfile and then copies only the packages the app needs. Keep the base directory empty and point the Dockerfile path at the app’s file:
A self-contained app with its own Dockerfile and no workspace dependencies builds from its own folder instead:

How webhooks are processed

Push and pull request webhooks from all four providers follow one path. Every webhook creates a delivery history entry, whether it succeeds, fails, or does not match, so you can see and replay failed deliveries. A push is acknowledged with 202 deploy queued: <id> as soon as the attempt is recorded; the clone and build run in the background, and the delivery’s note is updated to the outcome when the deploy ends. A delivery repeating a provider delivery id (X-GitHub-Delivery and equivalents) that already succeeded is answered with the original status and the note duplicate delivery. A byte-identical signed body repeated within APP_WEBHOOK_REPLAY_WINDOW (default 10m) is ignored with 200 and the note replayed body, whatever its delivery header says. A push whose commit is already deployed or in flight is ignored, as is a push for a repository other than the one the app tracks. A commit the repository does not have returns 422 commit not found. All four providers post to POST /api/v1/webhooks/github/{name}. The path says github for backward compatibility with webhooks configured before the other providers existed. The provider is detected from headers (X-GitHub-Event, X-Gitlab-Event, X-Event-Key, X-Gitea-Event-Type), not the URL. The route takes no session or token, because providers cannot send one. The per-app webhook secret, generated when the git source was connected, is checked against the request instead. Each request is limited per client IP and app name before any lookup or write happens, so a client that never produces a valid signature is rejected cheaply. The budget is APP_WEBHOOK_RATE_LIMIT_RPM requests per minute (default 60), refilled continuously so a burst of back-to-back pushes does not trip it. A request over budget gets 429 with Retry-After. Set it to 0 to disable the limit. A second budget per client IP across all app names, APP_WEBHOOK_IP_RATE_LIMIT_RPM (default 600), stops a client that tries many app names. An app with no git source answers 401 invalid signature like a bad signature and stores no delivery. A push whose ref does not match the git source’s trigger mode is accepted (200) and ignored. Pull request events are routed separately: opened and synchronize deploy or redeploy a preview (when previews are enabled), and closed tears it down whether or not the pull request merged.

Webhook deliveries

Every inbound request is recorded, signature valid or not, matched or not. Bad signatures, unconnected sources, and deploy failures all show up. The app’s Source tab (/apps/{name}/source) has a “Recent webhook deliveries” panel.
Replay runs the same processing against the stored payload and headers once you have fixed the problem, so it can trigger a real build and deploy. It does not re-verify the original signature (you are already authenticated with the deploy ability) and does not write a second delivery row, since the replay is in the audit log.
Rows are kept for 30 days by default (APP_WEBHOOK_DELIVERY_RETENTION_DAYS) and swept every hour (APP_WEBHOOK_DELIVERY_SWEEP_INTERVAL). Deliveries that fail signature verification are capped separately: only the newest 20 per app are kept (APP_WEBHOOK_FAILED_DELIVERY_KEEP) and each stores at most 2048 body bytes (APP_WEBHOOK_FAILED_BODY_BYTES). This is debugging data, not a compliance trail.
This prints the absolute webhook URL, the content type (application/json) and the events to subscribe to (push, pull_request). The URL is built from the primary domain, or from the address you called when none is set. The secret is only shown with --rotate, which mints a new one.

Rotate the webhook secret

Rotating mints a fresh secret without touching the repository URL, branch, build config, services, or deploy token. The old secret stops verifying the moment the call returns, so update the repository’s webhook settings with the new value before the next delivery.
The git source card has a matching Rotate secret button that shows the new value once. The API route is POST /api/v1/apps/{name}/git-source/rotate-webhook-secret.

Preview environments

Previews are opt-in per app and off by default. Once enabled, opening a pull request against the repository’s target branch deploys an independent copy of the app named <app-name>-pr-<number>. New commits redeploy it in place, and closing or merging the pull request tears it down. A single app with a persisted multi-service services: map fans a preview out the same way POST /api/v1/apps/{name}/deploy-spec does for a real deploy.
apps previews list shows one row per preview with its pull request number, preview app, branch, status, domain, last update, expiry, whether it is stale, and any ephemeral or isolated databases. extend adds hours to one preview’s expiry (default 24).

Domains

When a control-plane primary domain is configured, the preview gets pr-<number>.<app-name>.<primary-domain>. A domain collision does not fail the preview: it deploys without a domain, and status_reason says why. For a multi-service preview only one fanned-out service, the one that carried a domain in production, claims the subdomain. The rest are internal only.

Pull request comments and commit statuses

A second toggle, independent of previews themselves, works on all four providers:
When on, each preview deploy posts a levelrail/preview commit status on the pull request’s head commit: pending while building, success once live (with the preview URL), failure if the deploy failed. Messages are truncated to 140 characters on GitHub and 255 on GitLab. Each pull request also carries a single comment, found by a hidden marker and edited in place, showing the state (building, ready with the URL, failed with a short reason, removed with the reason), the commit, a built-by line linking the deploy page, and the last update time. On GitLab this is a single merge request note, updated in place and edited to removed when the merge request closes. Draft merge requests are not treated differently yet. If someone deletes it, the next update posts a fresh one. This uses the same connected provider credentials as repository and branch calls. If the repository is not hosted on the connected instance, or no provider is connected, it is a silent no-op that never fails the preview.

Preview environment variables

A preview inherits its parent app’s env vars wholesale (Env, SecretEnv, and VaultEnv copy unchanged). Every preview container also gets PREVIEW_URL (when a domain was assigned), PREVIEW_PR_NUMBER, PR_NUMBER (same value, kept if the app already defines it), and PREVIEW_BRANCH. Pipeline runs triggered by a pull request get the same three variables for the live preview built from their branch. To give previews a different value for one key, declare an override on the parent app:
In the dashboard this is the Preview env overrides card on the app’s Environment tab. Overrides apply the next time a preview is created or updated, never touch the parent app’s running deploy, and survive parent redeploys. They apply to single-service previews only. Branch-scoped overrides apply only when the preview’s head branch matches a pattern, either an exact name or a glob such as release/* (* matches any run of characters except /, so release/* matches release/1.0 but not release/1.0/hotfix). Resolution order is branch-scoped override, then the unscoped preview override, then the app’s own env.
--secret encrypts the value like apps secrets set does, and it is never returned once saved. Setting the same pattern and key again replaces the override. When two overrides for a key both match, the exact match wins. clear takes the override’s id from list or set, because a branch pattern can contain /. In the dashboard this is the Branch env overrides card on the Environment tab. Like the unscoped form, it applies to single-service previews only.

Databases in previews

A preview that declares ephemeralInPreviews databases in app.yaml gets its own disposable instance, removed with the preview. A database that declares isolatedInPreviews instead gets its own credential on the existing database (a Postgres role or a Redis ACL user) with no new container. See the app.yaml reference.

Limits, forks, and approval

The control plane caps live previews per app (APP_PREVIEW_ENV_MAX_PER_APP, default 10) and across the platform (APP_PREVIEW_ENV_MAX_TOTAL, default 50). 0 turns a cap off. When a new pull request would exceed a cap, the app’s policy decides:
  • evict_oldest (default): the oldest live preview is removed to make room, and its pull request comment says why.
  • reject: the new pull request is not deployed. Its row shows limit_reached with the reason, and the next push retries once a slot frees up.
A push to a preview that is already live never counts as a new preview, and pull requests waiting for approval hold no slot. A pull request whose head repository differs from the target repository gets no preview unless you opt in per app (allow_fork_previews, default off). A payload that names no repository is treated as a fork. The preview shows awaiting_approval and the pull request comment explains how to approve. Approving deploys that commit once, and a later push from the fork waits for approval again. A fork preview also never receives the app’s environment variables or secrets unless the separate allow_fork_secrets policy is on (--fork-secrets on apps previews settings).
Approving is a security decision: the fork’s code runs on your server, and with fork secrets on it runs with the app’s environment variables and secrets. The dashboard asks you to confirm, and the CLI requires --yes.
Set the per-app policy on the Source tab under Preview limits and safety, or from the CLI:
--ttl-hours overrides the platform TTL for one app, and 0 restores the default. apps previews settings <name> sets the same policy plus --fork-secrets, --max-previews, --memory, --cpu, --idle-sleep-minutes, --database, --seed-database and --gate.

Cleanup

A preview is removed when its pull request closes or merges, when it expires, when it is evicted, or manually.
teardown uses the same path as the automatic pull-request-closed webhook, so use it for stuck builds or after a partial teardown. The dashboard has a Tear down button on each preview row.
At startup the control plane repairs what a crash can leave behind: previews stuck in deploying longer than APP_PREVIEW_STUCK_AFTER (default 30 minutes) are marked failed, and preview services that no preview owns are removed with their containers.The TTL sweep covers a pull-request-closed delivery that never arrived. A background loop tears down any preview whose last update is older than APP_PREVIEW_TTL (default 7 days, or the app’s own --ttl-hours). sweep, or the Sweep stale previews button that appears once a preview is stale, runs it immediately. GET /api/v1/apps/{name}/previews returns a stale field showing what the next sweep would remove.

API reference

The root tier covers routes that read or write credential material itself, the same tier as PUT /api/v1/settings/ingress. The read:sensitive and write:sensitive tier covers repository, branch, and project listing and use-as-source: they disclose private repository names but never the connection’s credentials.

Known limits

Bitbucket’s repo:push payload marks each change as a branch or a tag, but the webhook parser discards that and always treats the change as a branch. A Bitbucket tag push is therefore never recognized, so release mode never deploys from Bitbucket. This fails closed: a tag push simply does not deploy.
Both have their own release webhook events that Levelrail does not subscribe to. A tag push on either still triggers release mode correctly.
use-as-source connects the repository and registers the webhook, but does not carry the OAuth token forward as the git source’s deploy token. A private repository only builds once you paste a personal access token into the app’s git source card. GitHub does not have this gap, because its installation token is minted fresh on every call. Likewise can_auth_clone in GET /api/v1/git-providers is true only for GitHub.
A GitHub Enterprise Server connection uses the instance’s own host for the App, for listing and for authenticated clones: a repository URL on the connected instance’s host gets the installation token, exactly like github.com. This is covered by unit tests only; it has not been run against a live Enterprise Server.
Disconnecting deletes the local connection and its secrets and, for GitLab, revokes the OAuth token. It never uninstalls the GitHub App or deletes the OAuth application on any provider, and Bitbucket and Gitea offer no API to revoke a token. The disconnect response and the toast say which of these applied.

When webhooks do not arrive

A push can reach a git source without a webhook ever being called: the webhook address was localhost, registration failed, or the git host was down. Git reliability describes what the control plane does about it: it flags an unreachable webhook address, shows registration failures with a Register again button, polls the branch head for missed pushes and ignores a late delivery for a commit older than the one already deployed.

Troubleshooting

Webhook is not triggering deploys

Likely cause: The provider connection is not set up, the webhook is not registered on the repository, or the webhook is pointing to the wrong URL. How to confirm: In the dashboard, go to Settings > Git integrations. Check that the provider is connected. Then open the app’s git source settings and verify the webhook secret is present and the status shows “registered”. Fix: Reconnect the provider if needed. Make sure the app’s git source has a valid webhook secret. If the webhook URL changed (for example, domain migration), re-register it by disabling and re-enabling the git source.

Build does not start after a push

Likely cause: The webhook is not configured, the app is not listening for webhooks, or the branch does not match the configured trigger branch. How to confirm: Check the app’s git source in the dashboard (App > Source). Verify the branch matches the pushed branch. Check webhook history in the dashboard if available. Fix: Verify the trigger branch matches where you are pushing. If the webhook is registered but not triggering, check the provider’s webhook delivery logs (on GitHub, GitLab, etc.). The control plane logs may also show webhook errors: journalctl -u levelrail | grep webhook.

Repository credentials are wrong

Likely cause: The provider credential was revoked, expired, or was never authorized to access the repository. How to confirm: Try to list repositories in the dashboard or CLI. If it fails with a 401 or 403, the credential is invalid. Fix: Disconnect and reconnect the provider, authorizing the new credential with access to the required repositories. For GitHub, you may need to approve the app on an organization, or check if app permissions changed.

Still stuck

For help with git integrations, check the webhook history in the dashboard (if available) or provider’s webhook delivery logs. Run levelrail-cli github-app repos (or the equivalent for other providers) to verify the connection is working.

Deploying and managing apps

The app lifecycle: deploy, rollback, resources, health checks.

Domains and ingress

Domains for production apps and preview environments.

Pipelines

Run tests and gated deploys on push, tag, or pull request.

app.yaml reference

The deployment spec behind multi-service deploys.

GitLab deployments and environments

With git.gitlab_deployments on (off by default), a deploy of an app whose source is on GitLab creates an environment named <app>/production or <app>/preview-<n> and a deployment with status running, then success, failed or canceled when the deploy ends. The environment links to the app URL, or to the app’s deployments page when it has none. Closing a merge request stops its preview environment. The call needs a token with the api scope and Developer access on the project: when the connection’s stored scopes lack api, the deployments_report capability reads needs_scope and nothing is sent. Set git.gitlab_deployments_connections to limit reporting to chosen connections. Each post and each failure shows on the app timeline with the error text masked.
Last modified on November 16, 2026