↵select↑↓navigateescclose
Search frappe-nix

App standards

GitHub settings

The optional rulesets and repository settings, the release flow, and how they are applied and audited.

Updated
Tags
  • app-standards
  • github
  • rulesets
  • releases
On this page

The CI gates and the release flow need a few repository settings to work, and rulesets to be worth anything: auto-merge is only as safe as the checks the integration branch requires. frappe-nix renders the settings and rulesets from an app's resolved configuration, and frappe-nix repo apply applies them, but only for an app whose profile turns on repo-policy (it is off in recommended). Without it nobody applies anything, and frappe-nix repo doctor tells you what the enabled modules rely on.

The release flow

release.yml runs releases with no GitHub App, or with the one ci.github-app names (see CI):

  1. release-please runs on every push to the integration branch, and on a daily schedule, because a GITHUB_TOKEN merge raises no push. It keeps the release PR open, and cuts the tag and the GitHub release once that PR is merged. It uses GITHUB_TOKEN, or the App's token when there is one, and then the release PR starts ci.yml and pr-policy.yml by itself.

  2. dispatch-ci, without an App only, runs ci.yml and pr-policy.yml on the release PR, because a push made with GITHUB_TOKEN starts no workflow. It checks each required check on the PR's head separately, so a run that failed or was cancelled is retried by the next one.

  3. fast-forward (develop+version only) moves the release branch, version-<major>, to the commit of the new tag with a REST PATCH that GitHub refuses unless it is a fast-forward (or creates the branch on the first release). It then reads the branch back and fails unless it equals the tag. Under frappe-major the tag must also start with <tag-prefix><major>..

  4. assets dispatches assets.yml on the release branch (or on the tag under main+tags) when pilot-assets is on.

  5. publish opens the Frappe marketplace registry PR when listing.publish is on and the repository variable MARKETPLACE_PUBLISH is true, using the REGISTRY_TOKEN secret, and appends the PR's link to the release notes.

Merging the release PR is the decision to ship. Nothing merges it automatically.

SettingNeeded by
Actions may create pull requests (Settings → Actions → General → Workflow permissions)release-please, the weekly relock, the screenshots PR, unless ci.github-app names an App
The ci.github-app App installed on the repository, its ID in an Actions variable and its private key in an Actions secret (both also Dependabot secrets with dependabot on)bot PRs that start CI without approval or dispatch (optional; see CI)
GitHub Actions may update version-* (the release-branch ruleset's bypass, or no ruleset there)the fast-forward
Auto-merge allowed, and a ruleset or branch protection requiring every enabled ci / <gate>Dependabot auto-merge, and with dependabot.auto-merge-policy = "all" the screenshots PR
Workflows write for the ci.github-app App (optional)dependabot.update-branches updating a bot PR across a change to .github/workflows/
REGISTRY_TOKEN secret and listing.registry-forkpublishing to the registry
FRAPPE_NIX_FETCH_TOKEN secret (Actions, and Dependabot)a private org profile, frappe fork or sibling

frappe-nix repo doctor

frappe-nix repo doctor                       # the app in the current directory
frappe-nix repo doctor example-org/my_app --format json

Read-only, and it needs no admin. For each setting the enabled modules rely on it prints ok, missing, or unknown (not readable without admin), with where to change it. It exits 1 when anything is missing. frappe-init --sync suggests it whenever it turns on a module that needs one of these settings.

Rulesets and settings

The templates live in frappe-nix's repo-policy/ (shipped in frappe-nix-tools, so an installed tool can read them). They are JSON with {placeholders} filled from the app's configuration:

FileAppliedWhat
rulesets/integration.json--phase fullThe integration branch: no deletion or force-push, PRs only with repo-policy.merge-methods, repo-policy.required-approvals, thread resolution, and the required checks
rulesets/integration-provisional.json--phase provisionalThe same without required checks, for a repository that has not opted in yet. The full ruleset has the same name and replaces it in place.
rulesets/release-branch.json--phase full, develop+version onlyversion-* moves only by the release automation: GitHub Actions is the only bypass actor (repo-policy.release-bypass)
rulesets/tags.json--phase full, with releasesRelease tags are never moved or deleted
repo-settings.jsonalwaysMerge methods, auto-merge, delete-branch-on-merge, squash commit title and message, secret scanning, Actions' default token permissions, vulnerability alerts, and the labels the enabled modules use

The required checks are one ci / <gate> per enabled gate, in the order pr-policy, lint, typecheck, test, marketplace, so a gate that is off is never required. repo-policy.required-checks may instead name a subset of the gates.

An org profile may replace any of these files with templates/repo-policy/<same path> (see Profiles).

frappe-nix repo apply

frappe-nix repo apply example-org/my_app --dry-run           # the JSON diff, nothing changed
frappe-nix repo apply example-org/my_app                     # settings, labels and the full rulesets
frappe-nix repo apply --all --fleet ../my-profile/fleet.json --phase provisional --rename-default-branch
frappe-nix repo apply example-org/my-profile --policy-dir repo-policy   # a directory of its own

It needs gh authenticated with repo scope and admin on the target (never admin:org). For each repository it reads the default branch's pyproject.toml and resolves the configuration. A repository that has not opted in yet is resolved with the profile --profile, its fleet entry or the fleet file names, and gets only --phase provisional. A repository whose resolved repo-policy.enable is false is skipped with a notice, so the tool never applies policy nobody asked for.

  • Rulesets are matched by name: a missing one is created, a different one is updated, and rulesets it doesn't know are listed, never deleted.

  • --rename-default-branch renames the default branch to the integration branch first when the latter doesn't exist (GitHub retargets open PRs).

  • Rulesets on a private repository need a paid plan; a 403 fails that repository with that message. A fleet entry with private: true is refused for --phase full.

  • If GitHub refuses GitHub Actions as a bypass actor, it stops for that repository and prints the two fallbacks: a machine user (repo-policy.release-bypass = "user:<id>"), or a deploy-key bypass through an org override of release-branch.json.

Exit status: 0 applied or already matching, 1 some repository failed (the rest continue), 2 a configuration error.

The fleet list

--all reads a fleet file, which belongs to the organisation (usually its profile repository), not to frappe-nix:

{ "schema": 1, "profile": "github:example-org/standards-profile/v1", "apps": [
  { "repo": "example-org/my_app", "app": "my_app", "private": false, "list": true,
    "documentation": "https://docs.example.org/my-app/" }
] }

An entry's profile and integration_branch override the file's for that repository; target_app and rename_mode describe a planned rename.

frappe-nix repo audit

frappe-nix repo audit --repo example-org/my_app --format json
frappe-nix repo audit --all --fleet fleet.json --issue --issue-repo example-org/standards-profile

The scorecard: for each repository, a shallow clone of the integration branch and rows A1 to A17 (the default branch, the release branch and tags, settings and rulesets, sync --check, CI and nightly status, ty, TypeScript, coverage and testmap, legacy tooling, Dependabot and drift, releases, README, icons, the listing, screenshots, the registry and the docs site). Each row is green, amber, red, n/a (its module is off) or unknown (unreadable, usually for lack of admin). It exits 1 on any amber or red.

frappe-nix ships .github/workflows/fleet-audit.yml as a reusable workflow only. An organisation calls it on a schedule from its own repository, with the fleet file and a read-only token:

jobs:
  audit:
    permissions:
      contents: read
      issues: write
    uses: Avunu/frappe-nix/.github/workflows/fleet-audit.yml@<sha> # v1.x.y
    with:
      fleet: fleet.json
      issue-repo: ${{ github.repository }}
      frappe-nix-version: v1.x.y
    secrets:
      FRAPPE_NIX_AUDIT_TOKEN: ${{ secrets.FRAPPE_NIX_AUDIT_TOKEN }}

FRAPPE_NIX_AUDIT_TOKEN is a fine-grained token with Administration and Contents read on the fleet's repositories. The scorecard issues are written with the calling repository's own token.

Rollout: how a frappe-nix release reaches the apps

A new frappe-nix release rewrites the caller workflows' pinned SHAs. GitHub refuses a workflow change pushed with GITHUB_TOKEN, so Dependabot never moves frappe-nix. frappe-nix's own .github/workflows/rollout.yml does, after every release, for the repositories frappe-nix's variable FRAPPE_NIX_ROLLOUT_REPOS names (spec §5.8):

  1. resolve (read-only, no secret) finds the release (release's head, the v* tag at that commit, merged into main through a PR) and, per repository, its integration branch, that branch's head and the frappe-nix it locks. It skips a repository already at the tag and pauses one where a person's commits on standards/frappe-nix are held by an open PR (or by no PR), or where this release's PR was closed unmerged.

  2. plan (read-only, no secret, no cache) runs frappe-nix repo rollout --emit-patch in a throwaway runner, as an unprivileged user with no token at all: the app's flake, relock, uv and yarn (without install scripts) and frappe-init --sync run there and nowhere else. The result is a patch, and a meta.json whose state publish checks for itself.

  3. publish (environment frappe-nix-rollout) checks that patch with the tag's frappe-nix ci verify-rollout-patch before any token exists. Lock files are read the way frappe-nix ci verify-relock reads a relock's (strictly, as yarn writes them and as the Nix build reads them), must come from trusted sources, and each lock entry must still be the files its name and version stood for at the base; every other file must be byte for byte what the tag renders. Then it mints the rollout App's token for that one repository, turns off any auto-merge an earlier run enabled (GitHub keeps it on across a push), commits the verified tree as that App's bot (rollout.yml's BOT), pushes standards/frappe-nix and opens or updates chore(deps): frappe-nix vX.Y.Z. That PR auto-merges once the integration branch's required checks pass (only when they require every enabled gate and the repository allows auto-merge, and only for the commit the rollout pushed: --head-sha), or is labelled needs-review with auto-merge off.

  4. report (the workflow's own token, Issues write, no secret) writes a per-repository table to the run summary and to the pinned issue "frappe-nix rollout status" in frappe-nix, and fails the run when a patch was rejected.

standards/frappe-nix belongs to the rollout. Push a fix to it (or amend or rebase the rollout's commit: a commit counts as the rollout's only when its bot both authored and committed it) and the rollout leaves it alone (with a comment) while its PR is open. Merge or close the PR and the next rollout replaces the branch (with --force-with-lease): a squash merge or a closed PR leaves your commits out of the integration branch, so take them there yourself. Close the PR unmerged and that release is skipped for the repository; the next release opens a new one. Commits that no PR holds (pushed with no PR open, or after the PR was closed) keep it paused until you delete the branch, or open a PR for them and merge or close it.

One-time settings in frappe-nix:

SettingValue
Environment frappe-nix-rollout (Settings → Environments)Deployment branches: main only; required reviewers if a person should approve each release's publish. Only the publish job runs in it. It holds the rollout App's credentials: the environment variable FRAPPE_NIX_ROLLOUT_APP_ID (the App's client ID) and the environment secret FRAPPE_NIX_ROLLOUT_PRIVATE_KEY.
Actions variable FRAPPE_NIX_ROLLOUT_REPOSUnset or empty: no repository. all: every repository in fleet.json. Otherwise a comma-separated list, each in fleet.json. Canary order: one app, then a second, then all.
The rollout App (a GitHub App of its own)Owned by the organisation, no webhook, repository permissions Contents, Pull requests, Workflows and Issues read and write, installed on the fleet's consumers only. Its key is the environment secret above and nothing else: not a repository or organisation secret, so no other workflow, job or branch of frappe-nix (nor any other repository) can mint its token, and the environment's main-only rule then guards it. rollout.yml does not use the CI App of CI or its key, so narrowing that secret's repositories does not affect it. Its bot login is rollout.yml's BOT. frappe-nix repo rollout reads that BOT from the frappe-nix repository the app locks, at the release it moves to, and counts a branch's chore(deps): frappe-nix commits as the rollout's own only when that exact login or you made them; any other bot's commit is someone else's.

Dispatch it by hand with gh workflow run rollout.yml -R <owner>/frappe-nix -f repos=<owner>/my_app -f dry-run=true to plan and verify without writing anything.

frappe-nix repo rollout, by hand

The manual fallback, and the mover for an org profile. It uses your own token, which must have the workflow scope:

gh auth refresh -s workflow
frappe-nix repo rollout --to v1.2.0 --repo example-org/my_app --dry-run
frappe-nix repo rollout --to v1.2.0 --all --fleet fleet.json
frappe-nix repo rollout --profile-to latest --all --fleet fleet.json

For each repository it clones the integration branch and runs nix flake update frappe-nix (and/or standards-profile), nix run .#relock and frappe-init --sync, with no token in their environment. It commits chore(deps): frappe-nix v1.2.0 and pushes the one branch standards/frappe-nix with --force-with-lease; it leaves alone a branch that has someone else's commits. It turns off an auto-merge an earlier run enabled before it pushes, opens or edits the PR, closes the old standards/frappe-nix-v* PRs and, unless --no-auto-merge, enables auto-merge for the commit it pushed under the same safety rule (else the needs-review label). The nightly drift issues and audit row A10 remind you when an app is behind. An app without CI callers needs none of this: nix flake update frappe-nix && frappe-init --sync in any commit is enough.

Landing a workflow change without a PAT

rollout.yml lands the workflow changes of a frappe-nix bump with the rollout App's token, which has Workflows write; no personal token is involved. Whether GITHUB_TOKEN alone could commit a change to .github/workflows/ through the Git Data API (blobs, a tree, a commit, then a ref PATCH) has not been tested, and nothing depends on it any more.