Skip to content

app/: onboarding through the GitHub App (sc-9027, PR 1 of 3) - #116

Open
ndbroadbent wants to merge 2 commits into
mainfrom
onboarding-installations
Open

ndbroadbent wants to merge 2 commits into
mainfrom
onboarding-installations

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

sc-9027, PR 1 of 3: the backend for onboarding through the GitHub App. Signing up now makes an empty personal organization. Installing the App makes the projects.

Installations

  • New tables:
    • github_installations: the installation, its account (id, login, type), the organization it was set up for, who set it up, suspended_at, deleted_at, and the last set-up's result.
    • user_installations: which installations each person can reach.
  • A GitHub sign-in records the installations GitHub lists for the person, and replaces their list.
  • The installation webhook:
    • created, unsuspend and new_permissions_accepted record the installation, and the installer can reach it at once.
    • suspend marks it suspended.
    • deleted marks it removed and clears who can reach it. The row stays, so a reinstall maps back to the same organization.
  • installation_repositories:
    • added, on an installation that's been set up, makes projects in its organization (as the sender if they're an admin there, else as whoever set it up).
    • removed keeps today's behaviour: the installation is detached from the linked projects, so checks stop. The repository URL is kept, so adding the repository back reattaches the same project instead of making a duplicate.

Setup URL: GET /github/setup?installation_id=… (app host). Set this as the GitHub App's Setup URL.

  • Signed out: sign in, then come back.
  • An installation the person's account can't reach yet: one more GitHub sign-in refreshes their list. If it's still not there, a page says so.
  • No installation ID (an organization owner still has to approve the request): a page says so.
  • Then the installation is set up, and the person lands on /{org}?setup=add_to_ci&installation={id}.
  • github is now a reserved organization slug.

Setting an installation up (forge::installations::set_up, also POST /api/ui/installations/{id}/setup for the checklist's "already installed on X" offer). It's safe to run again: repositories already linked are left as they are.

  • How the organization is chosen:
    • the person's own account → their personal organization;
    • a GitHub organization (or someone else's account) → the organization it was set up for before;
    • otherwise a new organization: slug is the lowercased login, or <login>-github with a note when that's taken; name from GitHub; the installer is admin. Other people join through the hourly sync.
  • Each granted repository the installer can Maintain becomes a project (slug from the repository name), linked through link_repository's checks.
  • Repositories they can't Maintain are listed with the reason ("you're write: ask an admin of acme to set it up"). So are archived repositories and repositories linked in another organization.
  • At most 100 repositories per set-up, flagged truncated when there are more.

Checklist

  • Steps are now install_github_app → add_to_ci → connect_agent → review_changes, with create_project gone.
  • install_github_app is done once an installation is set up for the organization.
  • The state adds:
    • install_url;
    • installations: the person's installations, each with its organization, or null for an offer;
    • github: each installation set up for this organization, with its last set-up result, for the "repos you can't Maintain" list.
  • MCP goldens are updated to match.

PR 2 (frontend) and PR 3 (end-to-end onboarding test) follow. Sign-ups stay closed until PR 3 is green and Nathan has walked through it.

Tests: tests/installations.rs, covering:

  • her own account;
  • a GitHub organization;
  • a taken slug;
  • someone who can't reach the installation;
  • the Setup URL's sign-in and refresh;
  • the API offer;
  • webhooks for created, added, suspend and deleted.

setup.rs and organizations.rs are updated. The full suite passes on a build box with Postgres 17 and RustFS.


Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…s recorded from sign-ins and webhooks; GET /github/setup maps an installation to an organization and makes a project per repository the person can maintain; no Default project; checklist install_github_app → add_to_ci → connect_agent → review_changes
…b (own account, an owner of the organization, or its installer) before any organization or mapping is written; the mapping is written only where none exists; GET /github/setup sets up only the install this browser started (state); personal organization by ID; orphaned goldens removed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant