Skip to content

GitHub App Setup

This is the recommended GitHub auth mode for teams sharing one Archon instance. It replaces the shared GITHUB_TOKEN PAT with a registered GitHub App so that:

  • Bot comments appear as archon[bot] with the App badge, not under an operator’s personal account.
  • Installation access tokens rotate automatically every ~1h (smaller blast radius if leaked).
  • Webhooks centralise — one URL per App covers every installation.
  • A team’s repos can span multiple GitHub orgs (or a mix of orgs and personal accounts) — Archon routes per-(owner, repo) to the right installation transparently.

Solo installs that only need the PAT model can ignore this page; see GitHub for the legacy setup.

SituationRecommended mode
Solo developer, single GitHub accountPAT
Team of 2+ sharing one Archon instanceApp
Repos across multiple orgsApp
You want bot comments to attribute as <slug>[bot] with App badgeApp
You want short-lived (1h) tokens instead of long-lived PATApp

Archon refuses to start with both modes configured. Pick one set of env vars.

  1. Go to https://github.com/settings/apps/new (or https://github.com/organizations/<org>/settings/apps/new for an org-owned App).

  2. Fill in:

    • GitHub App name — e.g. Archon Bot. The slug derived from this (visible in the App URL) is what you’ll later set as GITHUB_APP_SLUG. Self-filter compares against <slug>[bot].
    • Homepage URL — your team’s Archon URL, e.g. https://archon.example.com/.
    • Webhook URL — https://archon.example.com/webhooks/github.
    • Webhook secret — same value as your WEBHOOK_SECRET env var.

    Webhook bodies are limited to 32 MiB (33,554,432 bytes), inclusive. Larger bodies receive HTTP 413 before the signature is checked; Archon stops reading them and creates no receipt or workflow start. This limit applies only to webhook routes.

  3. Uncheck Active on the user authorisation callback URL — Archon doesn’t use OAuth in PR-B.

Repository permissions:

PermissionAccessUsed for
ActionsRead & WriteObserving GitHub Actions workflow runs and rerunning failed CI
ChecksReadWaking workflow CI waits when a check concludes
ContentsRead & WriteCloning, reading repo metadata, pushing branches, and merging pull requests
WorkflowsRead & WriteRequired only when runs create or change files under .github/workflows/
IssuesRead & WritecreateComment + listComments
Pull requestsRead & Writepulls.get + comment posting
MetadataReadMandatory (auto-included)

GitHub refuses pushes that create or change files under .github/workflows/ unless the App has Workflows: Read & Write, even when Contents: Read & Write is granted. See GitHub’s Git access permissions.

Account permissions: none.

Subscribe to:

  • Issue comments
  • Check runs
  • Pull request review comments
  • Pull request
  • Issues (used for closed cleanup)

Existing installations must accept the added Checks permission before check-run wake-ups work. If a check-run webhook is unavailable, delivery still progresses after the wait’s five-minute deadline and probes CI again.

  1. After saving the App, scroll to Private keys and click Generate a private key.
  2. Save the downloaded .pem file in a location only readable by the Archon process — e.g. /etc/archon/github-app.pem.

Install the App on every org or personal account that holds repos your team operates on:

  1. From the App settings page, click Install App.
  2. Pick the org → grant access to all repos (or selected repos).
  3. Repeat for every org/account.

Multi-installation: Archon resolves owner/repo → installation_id via GET /repos/{owner}/{repo}/installation automatically. No per-install config is needed. GITHUB_APP_INSTALLATION_ID only pins the installation used for adapter API operations — see below.

Add the following to ~/.archon/.env for the install or <cwd>/.archon/.env for the project:

GITHUB_APP_ID=123456 # numeric App ID, visible on the App settings page
GITHUB_APP_PRIVATE_KEY_PATH=/etc/archon/github-app.pem
WEBHOOK_SECRET=<same value as on the GitHub side>
# Optional:
# GITHUB_APP_SLUG=archon-bot # defaults to 'archon'; set this if you named your App
# # differently. The bot's posted-comment login is `<slug>[bot]`.
# GITHUB_APP_INSTALLATION_ID=98765 # use a fixed installation for adapter API operations.
# # Repository tokens still verify the repository installation.

CLI workflow run, --detach, resume, wake, and signal use GITHUB_APP_ID plus either private-key setting. They do not require WEBHOOK_SECRET; that setting is required for the server’s webhook adapter. Each detached child initializes its own provider from the inherited configuration.

Incomplete App settings, malformed App or installation IDs, an unusable RSA private key, and a malformed per-user encryption key fail before workflow execution. App/key correspondence and installation access are checked remotely when resolving the repository token. A resolution failure fails the run before any node executes; it cannot fall back to another credential. With no App settings, CLI behavior is unchanged. CLI runs follow the same per-user policy as server runs: connected user credentials override the bot, and unconnected users have GitHub credentials scrubbed unless org fallback is explicitly enabled.

Each workflow execution, including a resumed segment, resolves the codebase repository’s installation token. The provider caches fresh tokens in memory and refreshes them near expiry; tokens are not cached on disk. A node’s environment stays fixed during one execution, so this does not rotate tokens inside a workflow that runs longer than the token lifetime.

If you can’t write a file (e.g. a managed PaaS), set the PEM contents inline:

GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"

Archon normalises the literal \n sequence in .env-quoted values into real newlines.

Archon refuses to start if both modes are configured. Remove GITHUB_TOKEN from your env when switching to App mode.

  1. Restart the server.
  2. Confirm the startup log shows github.adapter_mode_app with your slug.
  3. Trigger a webhook from a repo where the App is installed (e.g. comment @archon ping on an issue).
  4. Confirm the bot’s reply appears as <slug>[bot] with the App badge in the GitHub UI.

Step 8 (optional): Enable per-user GitHub identity

Section titled “Step 8 (optional): Enable per-user GitHub identity”

By default GitHub API requests and pushes authenticate as the bot (<slug>[bot]), while commit authorship uses the checkout’s ambient git identity. On a multi-user install teammates can connect their own GitHub identity for authentication and commit authorship.

Enable the feature by adding two env vars on top of App mode:

Terminal window
# The App's Client ID (App settings → "Client ID", starts with Iv1./Iv23…).
# Distinct from the numeric GITHUB_APP_ID.
GITHUB_APP_CLIENT_ID=Iv23xxxxxxxxxxxx
# 32-byte key used to encrypt stored per-user tokens at rest (AES-256-GCM).
TOKEN_ENCRYPTION_KEY=$(openssl rand -hex 32)

Then, on the GitHub App settings page, enable Device Flow (under “Identifying and authorizing users”). The feature gate activates when GITHUB_APP_ID and TOKEN_ENCRYPTION_KEY are both set; GITHUB_APP_CLIENT_ID is required for the connect flow itself.

Teammates connect once via any surface:

  • CLI: archon auth github
  • Web UI: Settings → Connect GitHub

Once enabled:

  • Run commits use the initiating connected user’s GitHub login as author name and <numeric_id>+<login>@users.noreply.github.com as author email. The committer remains the ambient git identity. This applies to new and adopted worktrees, in-place runs, and folder projects without changing repository git config. Unconnected users and runs without an initiating user keep ambient authorship.
  • A connected user’s workflow gh/git authenticates with that user’s token. For git over HTTPS to https://github.com, the run resets every github.com credential helper and adds one that serves the user’s token, so neither the repository’s bot helper nor the host’s keychain or gh auth login answers for github.com in that run. Helpers for other hosts are untouched.
  • A start the CLI hands to a background executor, such as one archon trigger fire admits or a follow-up a run’s end starts, runs with its own run’s user’s GitHub identity, connected or scrubbed, not the identity of the process that started it. That covers the git Archon runs before the first node too (landing checks, worktree fetches, submodules).
  • Workflows declaring requires: [github] hard-block unconnected users before any worktree/clone/AI cost.
  • An unconnected user’s workflow gh/git has its GitHub token scrubbed by default (rather than silently using the shared org/bot token). The host’s GH_ENTERPRISE_TOKEN/GITHUB_ENTERPRISE_TOKEN are cleared for every per-user run. The scrub also hides the host’s stored logins: gh gets an empty config directory, so a gh auth login on the server is not used, and git’s credential helpers (keychain, credential store, gh auth git-credential) are cleared. GitHub commands in such a run fail with an authentication error until the user connects. SSH remotes still use the host’s SSH keys. Opt back into the shared token with ARCHON_ALLOW_ORG_GITHUB_TOKEN_FALLBACK=true.
  • Rotating TOKEN_ENCRYPTION_KEY invalidates all stored user tokens — everyone must reconnect.

This is fully backward compatible: leave the two vars unset and the App keeps working as the bot only. See the configuration reference for the full env var table.

Installation tokens are valid for 1h. Archon caches each installation_id → token pair and refreshes ~5 minutes before expiry on the next access. No background timer; no leaked handles.

event.installation.id short-circuits the lookup

Section titled “event.installation.id short-circuits the lookup”

Every webhook delivery from a GitHub App carries installation.id. Archon primes its owner/repo → installation_id cache from the payload, so the next outbound call to that repo skips the GET /repos/{owner}/{repo}/installation round trip.

A 401 from any installation Octokit evicts the cached token and the call is retried once with a fresh token. Persistent 401s propagate as the original error.

Workflows that span >1h need a fresh token to push from the cloned worktree. In App mode, Archon installs a git credential helper after cloning and refreshes it whenever it sets up an existing repository, including webhook handling and adding a codebase by URL: the worktree’s .git/config points at ~/.archon/bin/git-credential-archon, which talks back to Archon’s internal endpoint for a fresh installation token on each operation. A run of a connected user under per-user GitHub identity does not use this helper for github.com; it pushes with the user’s token. Git skips credential helpers when a remote URL carries credentials, so the same setup removes any token embedded in the repository’s https://github.com remote URLs, such as one left by an older PAT-mode clone. The helper reads the server’s port from ARCHON_PORT, which Archon sets for the processes it launches. A git command run from an independent shell on the Archon host gets no credential unless it exports ARCHON_PORT with the server’s port.

The helper is embedded in compiled binaries. Each setup replaces an outdated managed script and registers the helper and GitHub path forwarding in the repository’s local Git config. Existing repositories are refreshed on their next setup, not swept at server startup. If helper installation or registration fails, repository setup stops before URL registration, sync, or workflow dispatch; a later setup retries registration and repairs partial config.

A run’s GH_TOKEN and GITHUB_TOKEN hold the installation token resolved when the run, or a resumed segment, starts. That token can have as little as 5 minutes left. When the run’s process has ARCHON_PORT (every run the server dispatches, and a CLI run that exports the server’s port), Archon also puts ~/.archon/bin/gh-shim first on the run’s PATH. On each call the shim asks the same internal endpoint for a current token for the run’s repository and runs the real gh with it in the environment. If it gets no token, it exits 1 with a gh (archon shim): error instead of running gh with a stale token. A GH_TOKEN that is not an installation token, such as one a step sets itself, passes through unchanged. A per-user token or scrubbed token from per-user GitHub identity turns the shim off for that run.

gh keeps the start-time token, and fails once it expires, in these cases:

  • A CLI run without ARCHON_PORT. No endpoint is reachable, so Archon logs workflow.gh_token_refresh_unavailable each time it resolves the run’s GitHub environment. That happens when the run starts, when it runs worktree setup commands, and when it resumes, so one run can log it several times. The CLI mints its token at start, so it lasts about an hour. Export ARCHON_PORT with an App-mode server’s port to cover longer runs.
  • gh called by a Codex agent. Codex’s shell snapshot restores a fixed PATH, so its shell never finds the shim. Archon does not change that Codex setting. Bash, script and loop nodes, and Claude and Pi agents, use the shim.
  • Windows. The shim is a POSIX shell script, so a run on Windows logs the same warning and keeps the start-time token.

Run output redacts the start-time token only. A token the shim fetches later lives in the gh process’s environment, so it is not redacted if a step prints it, for example with gh auth token.

The credential-helper backend is exposed at POST /internal/git-credential and hands out live installation access tokens. It MUST NOT be reachable from outside the Archon host.

Archon enforces this at startup: with App mode active and the server bound to a non-loopback interface (e.g. 0.0.0.0), the process refuses to start and exits with github_app.internal_endpoint_public_bind_rejected. Two correct configurations:

  1. Recommended (bare-metal / systemd) — bind Archon to 127.0.0.1 (HOST=127.0.0.1) and put a reverse proxy in front. Configure the proxy to drop /internal/* paths.
  2. Opt-in escape hatch — ARCHON_ALLOW_INTERNAL_ON_PUBLIC_BIND=1 combined with HOST=0.0.0.0 (or unset). Use ONLY when your reverse proxy already drops /internal/* AND your deployment topology genuinely requires the upstream to bind non-loopback (e.g. a container network where loopback isn’t reachable from the proxy). Docker / docker-compose deployments fall here — the app container must bind 0.0.0.0 inside the container for docker-proxy to forward traffic, so option 1 isn’t directly usable. See the Canonical Docker setup below. Startup logs github_app.internal_endpoint_exposed_acknowledged so the choice is auditable.

Example Caddy snippet that drops /internal/* (bare-metal):

example.com {
@internal path /internal/*
respond @internal 404
reverse_proxy 127.0.0.1:3090
}

The canonical Archon Docker stack (docker-compose.yml + docker-compose.override.yml + Caddy) publishes the app container’s port 3000 and runs Caddy as a reverse proxy. Because the app container can’t bind 127.0.0.1 and still have docker-proxy forward traffic to it, option 1 above isn’t directly usable. Take option 2 with three layers of defense:

1. In docker-compose.override.yml — bind the published host port to loopback only.

services:
app:
ports: !override
- "127.0.0.1:${PORT:-3000}:${PORT:-3000}"

The !override tag (compose-spec) replaces the base file’s ports list instead of merging. After this, port 3000 is reachable only via the Docker network (where Caddy lives) or from the host itself — not from the public internet.

2. In Caddyfile — drop /internal/* requests.

The maintained Caddyfile.example includes this denial. Keep it in your deployed Caddyfile; if you use an older or custom configuration, insert it before the fallthrough handle { } block:

handle /internal/* {
respond "Not Found" 404
}

Caddy evaluates handle blocks by path specificity, so /internal/* (more specific) wins over the generic fallthrough regardless of order.

3. In .env — opt out of the loopback-bind guard.

# Safe because:
# 1. docker-compose binds port 3000 to 127.0.0.1 only (override above)
# 2. Caddy drops /internal/* (handle block above)
ARCHON_ALLOW_INTERNAL_ON_PUBLIC_BIND=1

Without this flag, Archon refuses to start in App mode and exits with github_app.internal_endpoint_public_bind_rejected.

Apply + verify:

Terminal window
# Apply the override + Caddyfile + env changes, then restart app + caddy.
docker compose up -d --force-recreate app caddy
# From outside the host — must be 404/403 from the proxy.
# Use POST (the endpoint's actual method) — a GET probe can false-pass when
# the proxy 404s unmatched GETs while still forwarding the POST upstream.
curl -i -X POST https://your-archon/internal/git-credential \
-H 'Content-Type: application/json' \
-d '{"host":"github.com","path":"any/repo"}'
# On the host — port should bind to loopback only
ss -tlnp | grep :3000
# Expected: 127.0.0.1:3000 (NOT 0.0.0.0:3000)
# Startup log should contain:
docker compose logs app --tail 200 | grep "internal_endpoint_exposed_acknowledged"
# This event confirms the opt-out path was taken (audit trail).

If the external POST probe returns anything other than 404 or 403 from the proxy — i.e. anything that suggests the request reached the Archon process — stop and fix the proxy config before going live. The endpoint hands out live installation tokens to whoever can reach it.

  1. Register the App and install on your orgs (Steps 1–5 above).
  2. Add GITHUB_APP_* env vars (Step 6). In Docker, put them in the container environment (the compose .env), not /.archon/.env; see GitHub CLI authentication.
  3. Remove GITHUB_TOKEN from your env (or comment it out). Archon refuses to start if both are set.
  4. Remove GH_TOKEN if you set it to the same PAT. Archon starts with it set, but the GitHub CLI in the container keeps using the old PAT.
  5. Restart Archon.
  6. Webhook URLs configured per-repo against the PAT-mode setup can stay or be removed — the App’s single webhook URL covers everything once it’s installed. New repos auto-join via App installation. While both webhooks are active, a comment delivered by each is deduplicated at ingest, so the bot still responds once.

In App mode, adding a private GitHub codebase by URL and inspecting its base branch use the repository’s installation token; no PAT is needed. The clone keeps a credential-free remote URL and receives the credential helper before registration completes. If the App is not installed, Archon reports installation guidance. Adding an already-registered URL refreshes the helper without cloning again when the checkout exists. A missing Archon-managed checkout is cloned again at its registered path. A missing operator-owned checkout must be restored or repaired with /update-project.

Run archon doctor to validate local App configuration after migration. A passing App check confirms the ID and RSA key are valid locally; it does not confirm GitHub accepts them or that the App has repository access.

AppPrivateKeyError: Provided value is not a valid PEM-encoded private key

Section titled “AppPrivateKeyError: Provided value is not a valid PEM-encoded private key”
  • Check the file content includes -----BEGIN ... PRIVATE KEY----- and -----END ... PRIVATE KEY-----.
  • For inline keys, ensure the .env value preserves newlines (either literal newlines in a multi-line value or the \n escape inside double quotes).

AppNotInstalledError: The Archon GitHub App is not installed on "<owner>"

Section titled “AppNotInstalledError: The Archon GitHub App is not installed on "<owner>"”
  • The App is not installed on that owner’s org/account. Use the install link in the error message to add it.

Repeated 401s on outbound API calls (createComment, listComments, repos.get, pulls.get) point at installation / token issues, not webhook config. Walk through:

  • Verify the App is installed on the target owner and has not been suspended or uninstalled. Visit https://github.com/settings/installations (or the org equivalent) to confirm.
  • Verify the private key in your env (GITHUB_APP_PRIVATE_KEY or _PATH) matches the same App that GITHUB_APP_ID points at. Mismatched key+ID is a common cause of “401 from JWT” errors at token-issuance time.
  • Verify GITHUB_APP_INSTALLATION_ID (if set) still corresponds to a live installation — uninstall + reinstall assigns a new ID.

An installation token needs Contents write access to push branches. If the branch creates or changes files under .github/workflows/, GitHub also requires Workflows write access. Check the App and installation permissions:

Verify the App’s permissions against the permissions table. Permission changes require operators to review and accept the new permissions on every installation; until accepted, that installation keeps its old permissions.

Webhook deliveries fail signature verification

Section titled “Webhook deliveries fail signature verification”

A webhook-secret mismatch causes github.signature_mismatch / github.signature_length_mismatch errors at the POST /webhooks/github endpoint — distinct from outbound API 401s. If GitHub’s webhook delivery page shows red ❌ next to the delivery (rather than your bot just silently not responding), check:

  • WEBHOOK_SECRET in Archon’s env matches the value entered in the GitHub App’s webhook configuration page exactly.

Bot comments still appear under your personal account

Section titled “Bot comments still appear under your personal account”
  • You’re still in PAT mode. Check process.env.GITHUB_TOKEN is unset and GITHUB_APP_ID is set; restart.

Server refused to start: github_app.internal_endpoint_public_bind_rejected

Section titled “Server refused to start: github_app.internal_endpoint_public_bind_rejected”
  • App mode is active but the server is bound to a non-loopback interface. This is a fail-fast guard — the /internal/git-credential endpoint hands out live installation access tokens and would leak credentials to the network. Either set HOST=127.0.0.1 (bare-metal / systemd), or, if you’re on Docker, follow the Canonical Docker setup above (port→127.0.0.1 binding + Caddy /internal/* drop + ARCHON_ALLOW_INTERNAL_ON_PUBLIC_BIND=1).

Server log shows github_app.internal_endpoint_exposed_acknowledged

Section titled “Server log shows github_app.internal_endpoint_exposed_acknowledged”
  • You set ARCHON_ALLOW_INTERNAL_ON_PUBLIC_BIND=1. Double-check that your reverse proxy actually drops /internal/* — a curl https://your-archon/internal/git-credential -d '{"host":"github.com","path":"any/repo"}' from outside the host must return 404 or 403 from the proxy (NOT a token from Archon). On the canonical Docker stack, also confirm ss -tlnp | grep :3000 shows 127.0.0.1:3000 (not 0.0.0.0:3000).