dotFactory
Documentation / Access and integration

GitHub

Access and integration

Signing in, connecting repositories, webhooks, and factories that live in a repo.

One GitHub App serves the whole integration. A deployment configures it from the environment; a person uses four different surfaces without having to think about that.

Signing in is not connecting repositories

  • Sign in with GitHub authenticates a person. GET /api/auth/github redirects to GitHub, and the callback maps the account's verified primary email onto a local User (linked by github_id). GitHub authenticates; it does not administer our users. Your memberships stay ours.
  • Connecting repositories grants access to a subset of the repositories the App installation covers. Open /github, connect, then choose the repositories to grant. The connection is a separate consent with its own OAuth scope (default repo read:org), and its token is stored through the secret codec.

The connection page lists what you may grant and what you have granted. Replacing the subset never revokes the connection itself; Disconnect does.

The App's roles

role what it needs
webhook FCT_GITHUB_WEBHOOK_SECRET; GitHub posts pull_request, issues and push deliveries to POST /api/github/<path>
installation tokens FCT_GITHUB_APP_ID + FCT_GITHUB_APP_PRIVATE_KEY; mints a short-lived token restricted to one repository and to the requested permissions
user login FCT_GITHUB_APP_CLIENT_ID + FCT_GITHUB_APP_CLIENT_SECRET
repository connection the connect OAuth flow (FCT_GITHUB_CONNECT_SCOPE, redirects via FCT_GITHUB_CONNECT_REDIRECT / FCT_GITHUB_CONNECT_SUCCESS)

The App signs a short-lived RS256 JWT for app-level calls. That JWT is never handed to a factory. A factory's GitHub effects use github_token(repo, scope), bound per Run to the factory's source repository and reduced to the permissions the step names. A local run with no provenance opts in with FCT_GITHUB_REPOS=owner/name,.... That is why no github credential is stored for the repository's own factory.

Webhooks

A kind: github trigger receives a verified delivery and admits a Run from its seed:

  • pull_request deliveries for a new commit on an open pull request;
  • issues deliveries for an opened or labeled issue;
  • push deliveries re-check repository-linked factories.

Every signature-verified delivery is stored raw — event, payload, headers, path, outcome — and deduplicated by event plus a canonical payload hash, so a GitHub redelivery or a poll of the same event is a no-op. A background poller in the worker asks the App for recent deliveries every five minutes and replays any push that did not arrive. manage.py github_sync is the manual form.

The trigger's target decides which repository a delivery is for; a delivery for another repository is ignored. Triggers shows the declaration.

Factories in repositories

A granted repository may carry:

  • a default factory at .fct/factory.fct;
  • named factories at .fct/factories/<name>/factory.fct.

A check reads the default branch at a pinned commit and proposes one candidate per root. Accepting a candidate creates the factory and its first version. The link is then pinned (publish an update explicitly) or follow (publish a push automatically). Versions keep their provenance: repository, path, ref and commit. Factories and versions covers the workflow.

A linked factory is repo-only: its Versions page does not offer Upload, and publishing a digest already stored records that repository on the version rather than creating a duplicate. Its latest version therefore always names the repository that scopes github_token.

A root that disappears becomes missing; the factory and its versions remain.

Opening issues and pull requests

Two effect steps make GitHub work without an agent shelling out to gh:

  • github_issue with config: { action: "open" } creates an issue from a title, an optional body and optional labels, and records its URL.
  • github_pull_request opens a pull request from an existing head branch into base, with a title and an optional body; config.draft opens it as a draft. head is a branch in the same repository or owner:branch for a fork. If that branch pair already has an open pull request, the step returns it instead of failing, so a retry is safe.
step file_issue:
  kind: github_issue
  config: { action: "open" }
  in:
    token:  github_token(repo: "owner/name", scope: { "issues": "write" })
    repo:   "owner/name"
    title:  triage.title
    body:   triage.body
    labels: ["bug"]

step open_pr:
  kind: github_pull_request
  config: { draft: false }
  in:
    token: github_token(
      repo:  "owner/name"
      scope: { "pull_requests": "write" }
    )
    repo:  "owner/name"
    head:  work.outcome.branch
    base:  "main"
    title: work.outcome.title
    body:  work.outcome.body

github_issue also keeps the worker loop's two existing actions: comment posts a body and release removes the claim label. See Adapters for the full inventory.

Permissions to ask for

  • Contents: read and Metadata: read — checking repositories and reading factory sources.
  • Push events — automatic follow updates.
  • Issues, Pull requests, Workflows — only if factories perform those effects (opening an issue, commenting, opening or merging a pull request, fixing a workflow run).
  • Installation tokens expire within the hour; a long agent step should keep its work under that limit, or mint a fresh token when it fires.

A fork, an automation change or anything the deployment cannot verify should be held rather than merged. That policy belongs to the factory, not to the App: the App only supplies the token.

Your factories

Your factories will appear here. Create one and open it beside this guide.