npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

octoops

v1.52.0

Published

Declarative GitHub repo configuration using the gh CLI

Readme

octoops

Declarative GitHub repo configuration using the gh CLI.

Maintain a JSON config describing desired state for your org's repos. Running octoops reconciles actual state with desired state using gh api calls. Idempotent and safe to run repeatedly.

npm install -g octoops

Usage

octoops apply config.json
octoops apply --dry-run config.json
octoops apply --audit config.json

Import an existing org into a config file:

octoops import my-org > config.json
octoops import my-org -o config.json
octoops import my-org --only members
octoops import my-org --only members,teams
octoops import my-org --only secrets
octoops import my-org --only runners

Seed state from an existing config (skips GitHub API calls):

octoops seed config.json

Resync state from live GitHub (use this if your state file got out of sync):

octoops resync config.json

Check a config for mistakes without touching GitHub:

octoops lint config.json
octoops lint org-manifest.json

It runs every check apply does before its first API call (unknown properties, unknown presets and defaults, malformed secrets, team members missing from admins/members, an app declared in two places) and exits non-zero on an error. Given a manifest it lints each included file and also catches an app that sits in the root apps list of one file and on a repo entry in another.

Print a repo entry the way apply sees it, with extends, defaults and presets all resolved:

octoops preview config.json --repo my-repo
octoops preview org-manifest.json --repo my-org/my-repo
octoops preview config.json

The output is JSON on stdout, one object for a single match and a list otherwise. The file each entry came from is printed on stderr. It reads only the config, not GitHub or the state file, so it shows what is declared, not what would change (that is apply --dry-run). Org-level settings that reach a repo from outside its entry, the root apps list and orgSecrets, are not folded in.

Apply a manifest that orchestrates multiple configs in one shot:

// org-manifest.json
{
  "includes": [
    "./team-a/config.json",
    "./team-b/config.json",
    "./tooling/config.json"
  ]
}
octoops apply org-manifest.json

Each include is resolved relative to the manifest file and applied in order. Each gets its own <name>.state.json next to it — manifests don't share state. Manifests can include other manifests recursively (cycles error out). A manifest is orchestration-only; it can't also declare org/repos/teams/etc. — octoops errors if both are present so the file's role stays clear.

Rename a repo on GitHub and rewrite the config + state file in one shot:

octoops rename config.json old-name new-name
octoops rename --dry-run config.json old-name new-name

The repo entry must live in the file you pass — extends/shared files are not searched. The config may hold either the old or the new name. The state key (<org>/<old>) is rewritten to <org>/<new> so subsequent applies see no diff.

Just changing name in the JSON and running apply does not rename — it creates a new empty repo and leaves the old one alone. To rename declaratively, set renamedFrom on the entry instead and apply renames the GitHub repo (see the field below).

If the new name is already taken (typically by the empty repo such a mistaken apply left behind), octoops refuses. Delete it yourself with gh repo delete <org>/<new-name> and rerun — octoops never deletes repos.

Respects GitHub API rate limits automatically.

Configuration

{
  "org": "my-org",
  "presets": {
    "standard-teams": [
      { "name": "backend", "permission": "write" },
      { "name": "devops", "permission": "admin" }
    ]
  },
  "repos": [
    {
      "name": "my-service",
      "description": "Does the thing",
      "private": true,
      "merging": { "squashOnly": true, "deleteBranchOnMerge": true },
      "topics": ["nodejs"],
      "teams": "$standard-teams",
      "branchProtection": [
        { "branch": "main", "enforceAdmins": true, "requiredReviews": { "approvals": 1 } }
      ],
      "environments": [{ "name": "production", "reviewers": [{ "team": "devops" }] }],
      "rulesets": [
        {
          "name": "protect-workflows",
          "include": ["~ALL"],
          "filePathRestrictions": [".github/workflows/**"],
          "bypassActors": [{ "team": "devops" }]
        }
      ],
      "npm": {
        "trustedPublishing": { "workflow": "release.yml", "environment": "production" }
      }
    }
  ]
}

Presets

Any string of the form "$name" — anywhere in the config, at any depth — resolves to the presets entry called name. This lets you define something once and reuse it across repos, teams, environments, rulesets, whatever:

"presets": {
  "reviewers": [{ "team": "release" }, { "team": "devops" }],
  "integrity": { "name": "integrity", "preventForcePush": true },
  "tags": { "name": "tags", "target": "tag", "preventCreation": true }
},
"repos": [
  {
    "name": "api",
    "rulesets": ["$integrity", "$tags", { "name": "ad-hoc", "preventDeletion": true }],
    "environments": [{ "name": "production", "reviewers": "$reviewers" }]
  }
]
  • A ref can resolve to any JSON value — string, number, object, array
  • A ref inside an array is spread if it resolves to an array, so ["$reviewers", { "team": "sre" }] becomes the two preset entries followed by { "team": "sre" }. Inline values pass through unchanged
  • An object inside an array fans out if its team, username or app field is a ref that resolves to an array. With "publishers": ["release", "devops"], "reviewers": [{ "team": "$publishers" }] becomes [{ "team": "release" }, { "team": "devops" }], and any other fields on the object (mode, filePatterns, minApprovals, ...) are copied onto every entry. A ref resolving to a single string stays one entry, so a preset can switch between one and several teams without touching the repos that use it. Only these three fields fan out, so refs on array-valued fields like filePatterns substitute as usual
  • Presets can reference other presets. Cycles are an error
  • An unknown ref is an error (with a did-you-mean suggestion), so typos fail at load instead of reaching GitHub. Refs are only resolved when the config has a presets map at all
  • Only whole strings are refs — "costs $5" is left alone. Write "$$name" for a literal string starting with $name
  • Refs are resolved once, after all extends files are merged, so a base file can declare a preset and a leaf file reference it. They work inside defaults entries, teams, security, runnerGroups — anywhere, not just under repos

Repo-local presets

A repo entry can also carry its own presets map. Those presets are only visible inside that entry, so a one-off value stays next to the repo that uses it instead of cluttering the root map:

"presets": {
  "reviewers": [{ "team": "release" }]
},
"repos": [
  {
    "name": "api",
    "presets": {
      "reviewers": [{ "team": "api-owners" }],
      "envs": ["production", "staging"]
    },
    "environments": [{ "name": "$envs", "reviewers": "$reviewers" }]
  },
  {
    "name": "web",
    "environments": [{ "name": "production", "reviewers": "$reviewers" }]
  }
]
  • A local preset shadows a root preset of the same name, so $reviewers is api-owners inside api and release everywhere else
  • Scoping is dynamic: the shadow also applies to refs reached through a root preset or a defaults entry. If a shared code-review ruleset reads $review, a repo that sets "presets": { "review": "data-structures" } gets that team in the ruleset without restating the ruleset, whether it lists "$code-review" itself or inherits it via defaults. Every ref that resolves to review inside that repo switches, so check what else in the shared presets reads it
  • Local presets can reference root presets and other local presets, and the same spread and fan-out rules apply. Cycles are an error
  • Other repos and the root config cannot see a repo's local presets — referencing one from elsewhere is an unknown-preset error
  • Local presets work even when the config has no root presets map
  • The presets map is removed from the entry once resolved, so it never reaches GitHub. Local presets are $ref-only; the older bare-string style below only looks at the root map

Older style

Before $refs, presets were referenced with a bare string in one of a fixed set of repo fields: merging, teams, topics, branchProtection, environments, rulesets, npm, pypi. That still works — "teams": "standard-teams" and "rulesets": ["integrity", "tags"] resolve as before — but new configs should use "$standard-teams" and ["$integrity", "$tags"], which work on every field.

Repo settings

Top-level repo fields for basic settings:

  • description — repo description
  • homepage — repo homepage url
  • private: true|false — visibility
  • internal: true — internal visibility (Enterprise only, overrides private)
  • defaultBranch — default branch name (e.g. "main"). Only applied if that branch already exists on the repo, otherwise skipped with skip-default-branch. Pair it with init: true to have octoops create it
  • wiki: true|false — enable/disable repo wiki
  • projects: true|false — enable/disable repo projects
  • issues: true|false — enable/disable repo issues
  • discussions: true|false — enable/disable repo discussions
  • archived: true — archive the repo (skips further reconcile). A repo that does not exist yet is created (and initialized if init: true) before being archived. Removing this from the config (when state has it) unarchives the repo
  • renamedFrom — previous GitHub name of this repo. Apply renames that repo to name (keeping history) and moves the state entry, instead of creating a new empty repo. Once done it is recorded in state and not re-checked, so it is safe to leave in the config. If neither name exists on GitHub the repo is created as usual. Only on repo entries, not on defaults
  • deleted: true — delete the repo on GitHub. Must be set on the repo entry itself (ignored on defaults packs). Removing a repo from the config does not delete it. A 404 (already gone) is treated as success. The delete is recorded in state as { "deleted": true }, so the entry can stay in the config and later applies skip it without calling GitHub. Dropping the deleted flag again clears that record and the next apply recreates the repo. Remove the entry from the config once you no longer need the reminder
  • init: true — initialize the repo with a README so the default branch exists. On create, passes --add-readme to gh repo create. On an existing empty repo (no branches), creates README.md retroactively. GitHub names that initial branch itself (per the org's default), so if defaultBranch is also set and differs, octoops renames the branch to match (rename-branch). The rename only ever runs on the commit octoops just made — a repo with existing branches is never touched. Once initialized, recorded in state and not re-checked
  • actionsAccess — "none" | "organization" | "enterprise". Controls which other repos' GitHub Actions workflows can access this repo's actions and reusable workflows (Settings → Actions → General → Access). Only relevant for private repos.
  • forkPrContributorApproval — "all_external_contributors" | "first_time_contributors" | "first_time_contributors_new_to_github". Controls who must wait for approval before GitHub Actions runs on fork pull requests (Settings → Actions → General → Fork pull request workflows from outside collaborators).
  • template — overloaded by type:
    • "owner/repo" — create the repo from a template repo. Only used at create time. Mutually exclusive with init (templates already have content).
    • true / false — mark this repo as a template (so others can "Use this template"). Settable on existing repos via the settings PATCH.
  • merging — { squashOnly, deleteBranchOnMerge, squashMessage }
    • squashOnly: true allows only squash merging; squashOnly: false allows merge commits and rebase merging and turns squash merging off
    • squashMessage — the default squash commit message. As in the UI, it's a sub-option of squash merging: setting it turns squash merging on (other merge methods are left as they are), and combining it with squashOnly: false is an error. The values match the four choices under "Allow squash merging" in Settings → General → Pull Requests:
      • "default" — Default message (commit title for a single commit, PR title otherwise; commit messages as the body)
      • "pr-title" — Default to pull request title
      • "pr-title-commits" — Default to pull request title and commit details
      • "pr-title-description" — Default to pull request title and description
  • pages — GitHub Pages site: { build: "workflow" | "branch", branch, path, private }. build: "workflow" (the default) deploys from Actions (actions/deploy-pages); build: "branch" serves branch at path (default /). private: true limits the site to people with read access to the repo; it needs enterprise: true and is skipped with skip-pages-private otherwise. pages: false removes the site. The site is created if missing and updated in the same apply, so a private: true site is never public with content on it (a new site has nothing deployed until a workflow or branch push does). Omitting pages leaves the site untouched

Omitting a field leaves the current GitHub value untouched. Setting it makes octoops reconcile it.

That holds for plain settings. Anything an apply created and recorded in state (teams, collaborators, topics, branch protection, rulesets, environments, secrets, npm trusted publishers, app repo access, org teams, org members, org secrets, runner groups, hosted runners) follows one rule: in state but no longer in the config means it is removed on the next apply. Removing a whole key is the same as emptying it. State is the only thing that drives this, so anything made by hand that no apply ever recorded is left alone; resync brings such things into state. The exceptions are a repo entry itself (needs deleted: true, see below) and values that cannot be unset, such as npm maintainers and deprecation.

Sharing config across files

A config file can extends one or more other files. This lets multiple teams share a common base of defaults, presets, etc:

// shared.json
{
  "defaults": {
    "base": { "private": true, "wiki": false }
  },
  "presets": {
    "default-rules": [
      { "name": "main", "preventForcePush": true, "requirePR": { "approvals": 1 } }
    ]
  }
}
// team-a.json
{
  "extends": "../shared.json",
  "org": "my-org",
  "presets": {
    "team-a-rules": [...]
  },
  "repos": [
    { "name": "api", "defaults": "base" }
  ]
}

Resolution rules:

  • extends is a string or array of paths. Paths are relative to the file declaring them.
  • Files are loaded recursively (extended files can extend further). Cycles error.
  • Deep-merge: objects merge per key, arrays/scalars replace.
  • The presets and defaults maps join at the key level — a name defined in the leaf replaces the parent's value for that name wholesale (no deep-merge into it), while names only the parent defines are inherited. So you can declare a preset in a base file and fully redefine it in the leaf without inheriting stale fields.
  • The leaf's own fields override the merged base.
  • State files belong to the leaf config (team-a.state.json), not the shared file.

Defaults

Define named defaults at the top level and let repos opt in via defaults: "name". Defaults can chain via extends:

{
  "org": "my-org",
  "defaults": {
    "base": {
      "private": true,
      "merging": { "squashOnly": true, "deleteBranchOnMerge": true },
      "wiki": false,
      "projects": false
    },
    "service": {
      "extends": "base",
      "teams": [{ "name": "backend", "permission": "write" }],
      "rulesets": "$default-rules"
    },
    "oss-module": {
      "extends": "base",
      "private": false,
      "rulesets": "$oss-rules"
    }
  },
  "repos": [
    { "name": "api", "defaults": "service" },
    { "name": "web", "defaults": "service", "topics": ["frontend"] },
    { "name": "lib-foo", "defaults": "oss-module" },
    { "name": "internal-thing" }
  ]
}

Resolution rules:

  • extends and defaults accept a string or an array. Array form is left-to-right, rightmost wins: extends: ["a", "b"] starts from a and layers b on top.
  • Each name is fully resolved (its own extends walked) before being used as a layer.
  • Objects deep-merge (so a repo can override merging.squashOnly without clobbering merging.deleteBranchOnMerge).
  • Arrays and scalars replace.
  • Repo fields override the resolved defaults.
  • Cycles or unknown names are an error.
  • $refs inside a defaults entry are resolved in the repo's scope before the merge, so a repo's local presets apply to them. Old-style bare-string presets still resolve after the merge (so rulesets: "default-rules" keeps working too).

Example with mixin composition:

{
  "defaults": {
    "private-base": { "private": true, "wiki": false },
    "squash-merging": { "merging": { "squashOnly": true, "deleteBranchOnMerge": true } },
    "service": {
      "extends": ["private-base", "squash-merging"],
      "teams": [{ "name": "backend", "permission": "write" }]
    }
  },
  "repos": [
    { "name": "api", "defaults": "service" },
    { "name": "frontend", "defaults": ["service", "frontend-mixin"] }
  ]
}

GitHub Advanced Security

Per-repo, under security:

{
  "name": "my-repo",
  "security": {
    "advancedSecurity": true,
    "secretScanning": true,
    "secretScanningPushProtection": true,
    "secretScanningValidityChecks": true,
    "dependabotSecurityUpdates": true,
    "codeScanningDefaultSetup": true
  }
}

Maps to the repo's security_and_analysis settings; codeScanningDefaultSetup toggles the code-scanning default setup via its own endpoint. If GHAS isn't available on the plan/repo (private without GHAS, forks, etc.) the relevant calls log skip-code-scanning and continue.

Org-level defaults for newly-created repos can be set at the top level:

{
  "org": "my-org",
  "security": {
    "advancedSecurity": true,
    "secretScanning": true,
    "secretScanningPushProtection": true,
    "dependabotAlerts": true,
    "dependabotSecurityUpdates": true
  }
}

These map to GitHub's *_enabled_for_new_repositories fields on the org settings — they only affect freshly-created repos; existing repos need the per-repo block.

GitHub Packages visibility

Track the desired visibility of a repo's GitHub Packages by attaching githubPackages to the repo entry. Accepts a single object or an array:

{
  "repos": [
    {
      "name": "my-tool",
      "githubPackages": { "visibility": "private" }
    },
    {
      "name": "foo",
      "githubPackages": [
        { "name": "@my-org/foo", "visibility": "private" },
        { "name": "@my-org/foo-cli", "visibility": "private" }
      ]
    }
  ]
}

Fields:

  • name — optional, defaults to the repo name. Use the full package name (with @scope/ prefix for scoped packages).
  • visibility — required, one of "public" | "private" | "internal".
  • type — optional, defaults to "npm". One of npm, container, docker, maven, rubygems, nuget. Docker images published to ghcr.io are "container", not the default npm — if the type is wrong the lookup 404s; octoops then probes the other types and tells you which one to set.

Behavior:

  • GitHub has no REST API to change package visibility — it's web-UI only. So octoops can't flip it for you: when the live visibility differs from config it prints a package-visibility-manual line with the exact settings URL (Package settings → Danger Zone → Change visibility) for you to click once. It does detect and report the drift.
  • Apply errors if the package isn't published yet on GitHub Packages — publish it first (e.g. via your trusted-publishing workflow).
  • No-op when current visibility already matches.
  • Tracked in state on the repo; removing an entry from config leaves the package's visibility untouched.
  • Your gh auth needs read:packages to read the current visibility — gh auth refresh -h github.com -s read:packages if you hit a 403.

GitHub Apps installation scope

Declare which repos each org-installed GitHub App can access. Octoops looks up the installation by app slug, then adds/removes repos from its selected list to match:

{
  "org": "my-org",
  "apps": [
    { "name": "dependabot", "allRepos": true },
    { "name": "holepunchto", "repos": ["repo-a", "repo-b"] }
  ]
}

Fields per entry:

  • name — required, the app's slug (the part after github.com/apps/, same one used in ruleset bypassActors: [{ app: "..." }]). You can also give the app's display name — octoops lowercases it and replaces spaces with - to match the slug (e.g. "My App" → my-app).
  • Exactly one of:
    • allRepos: true — the installation grants access to all current and future repos.
    • repos: ["..."] — explicit list of repo names in the org.

Behavior:

  • Errors if the app isn't installed on the org (installation itself is UI-only).
  • Errors if the config's scope (allRepos vs repos) doesn't match the installation's current scope — that toggle is UI-only, with a link in the error to the settings page.
  • For repos: [...], octoops state-tracks the applied list and PUTs/DELETEs individual repos to converge with the desired one. Idempotent PUTs; DELETE 404s are treated as already-removed.
  • Diffed against a normalized (repos sorted) shape, so a no-op apply skips the API calls entirely.
  • An app removed from the config loses the repos state recorded for it (app-remove-repo). One with allRepos is reported as skip-app, that scope is UI-only.

Token requirements — this feature has stricter auth than the rest of octoops:

  • You must be the Organization Owner (not just admin/member).
  • You must be the user who originally installed the app on the org — GitHub scopes installation-modification permissions to the installer, not to any org owner.
  • You must supply a classic Personal Access Token (not the token gh auth login mints via OAuth). GitHub CLI's OAuth token is scoped to the "GitHub CLI" app and can't modify other apps' installations, even with correct org role and scopes.

Create the classic PAT at github.com/settings/tokens → Tokens (classic) → Generate new token, with scopes:

  • admin:org
  • repo
  • read:user

If the org enforces SAML SSO, click Enable SSO → Authorize for the org on the token page.

Then run apply with GH_TOKEN set for that invocation so your regular gh auth stays untouched:

GH_TOKEN=ghp_yourpathere octoops apply your-config.json

Apps on the repo entry

Instead of listing repos under the app, a repo can name the apps it wants. This is the form that works in a defaults pack, and it follows the repo through renames:

{
  "org": "my-org",
  "defaults": {
    "service": { "apps": ["my-ci-bot"] }
  },
  "repos": [
    { "name": "api", "defaults": "service" },
    { "name": "web", "apps": ["my-ci-bot", "dependabot"] }
  ]
}
  • Entries are app slugs, or { "name": "..." }. Display names are matched the same way as on the root list.
  • Missing apps are given the repo (add-app), and an app octoops gave the repo that the entry no longer lists is taken off it (remove-app). apps: [] takes back everything octoops gave. Access granted in the UI was never recorded and is left alone.
  • An app installed with access to all repositories already covers the repo, so nothing is called and it is reported as skip-app. Taking such an app off a repo is also a skip-app, that scope is UI-only.
  • Errors if the app isn't installed on the org.
  • An app goes in the root apps list or on repo entries, never both. The same app in both places is an error, octoops lint on a manifest catches it across files too.
  • Which apps a repo was given lives only in the state file, GitHub won't list it for a token. resync keeps it, deleting the state file forgets it.
  • --dry-run diffs config against state and reads the org's installations, it does not write.

The token requirements above apply to both forms. With the repo form the calls happen while each repo is reconciled, so an apply with the wrong token stops at the first repo whose apps changed.

Runners

Manage self-hosted runner groups and GitHub-hosted larger runners at the org level. Octoops doesn't provision the underlying machines for self-hosted runners — those still register with GitHub the usual way — but it manages how they're grouped and which repos can use them.

{
  "org": "my-org",
  "runnerGroups": {
    "ci": {
      "visibility": "selected",
      "repos": ["api", "web"],
      "allowsPublicRepositories": false,
      "restrictedToWorkflows": ["my-org/ci/.github/workflows/*"]
    },
    "release": {
      "visibility": "private"
    }
  },
  "hostedRunners": {
    "build-8core": {
      "size": "8-core",
      "image": "ubuntu-22.04",
      "runnerGroup": "ci",
      "maximumRunners": 3
    }
  },
  "pruneOfflineRunners": true
}

Runner group fields:

  • visibility — "all" | "selected" | "private". Default "all".
  • repos — when visibility is "selected", the list of repo names that can use this group.
  • allowsPublicRepositories: true|false — whether public repos in the org can use this group.
  • restrictedToWorkflows: ["my-org/repo/.github/workflows/*"] — restrict to specific workflow refs.

Hosted runner fields:

  • size — required, e.g. "4-core", "8-core", "16-core". Match what your plan exposes.
  • image — required, image id or display name (e.g. "ubuntu-22.04", "windows-2022").
  • runnerGroup — required, name of a runner group (octoops resolves to id).
  • maximumRunners — optional cap on parallel runners.
  • enableStaticIp: true — optional static IP allocation.

Other:

  • pruneOfflineRunners: true — remove offline/stale self-hosted runners at the org level on every apply.

Groups and hosted runners in state but not in config are deleted. Default runner groups (Default) are never deleted even if they're not in config.

import reads runner groups and hosted runners from GitHub, leaving out the default group and groups inherited from the enterprise. resync reads the ones the config names and records them as they are on GitHub, so a group or runner removed by hand is created again on the next apply and one that drifted (the repos of a selected group, say) is set back. Fields the config leaves out are not recorded. seed records them straight from the config.

Environments

Each entry in environments supports:

  • name — required
  • reviewers: [{ team }] — required-reviewer teams (deployments are gated until one approves). On private repos this requires GitHub Enterprise; otherwise octoops prints skip-environments unless enterprise: true is set
  • preventSelfReview: true — block the actor who triggered a deployment from approving it themselves
  • deploymentBranches — which refs may deploy to the environment. Omitted means any branch. "protected" limits it to protected branches. A list limits it to the given name patterns: a string or { "branch": "release/*" } matches branches, { "tag": "v*" } matches tags. Patterns use GitHub's branch-policy syntax (* and **). The list is reconciled, so a pattern removed from config is deleted on GitHub
  • secrets — list of secret names, see "Secrets" below

An environment in state that is no longer in the config is deleted (remove-environment), its secrets and branch policies with it.

"environments": [
  { "name": "npm", "reviewers": [{ "team": "release" }], "preventSelfReview": true, "deploymentBranches": ["main", { "tag": "v*" }] },
  { "name": "staging", "deploymentBranches": "protected" }
]

Secrets

Declare the names of the Actions secrets a repo or environment should have. Values are never stored in config or state: apply prompts for them on the terminal.

{
  "name": "my-repo",
  "secrets": ["NPM_TOKEN", "SLACK_WEBHOOK"],
  "environments": [
    { "name": "production", "secrets": ["NPM_TOKEN"] }
  ]
}

Behavior:

  • State records which names have been set. A declared name missing from state is prompted for and set with gh secret set (value over stdin, never on the command line, never logged). Names removed from the config are deleted from GitHub
  • A value is prompted for once per name per apply and used for every repo, environment and org secret in that config that declares it. Two repos that need different values need different names
  • octoops apply --invalidate NPM_TOKEN,SLACK_WEBHOOK config.json prompts for those names again and sets them everywhere they are declared. That is how you rotate a secret. A name that matches nothing prints a warning
  • The prompt hides what you type. Paste works, including multiline values like PEM keys: bracketed paste is enabled so newlines inside a paste are data. Enter or Ctrl-D submits, Ctrl-C aborts the apply (secrets already set in that run stay recorded). On a terminal without bracketed paste a multiline paste stops at its first newline, so submit it with Ctrl-D instead. An empty value is re-prompted
  • When stdin is not a terminal (CI, apply.sh | tee), octoops prints skip-secret for any name that needs a value and leaves it for an interactive run. Deletes still happen, they need no value
  • Dry runs never prompt. They print prompt-secret NAME once and set-secret per target
  • import and resync read secret names from GitHub, so state can be rebuilt. A secret deleted by hand disappears from state on resync and is prompted for again on the next apply
  • Removing secrets from a repo entry, or emptying it, deletes every secret state knows about. Secrets never recorded in state are left alone

Org secrets

Org-level Actions secrets and which repos can read them. Visibility is all, private (private and internal repos) or selected, which takes a repos list.

{
  "org": "my-org",
  "orgSecrets": {
    "NPM_TOKEN": { "visibility": "selected", "repos": ["api", "web"] },
    "SLACK_WEBHOOK": { "visibility": "private" },
    "CODECOV_TOKEN": { "visibility": "all" }
  }
}
  • Values are prompted for exactly like repo secrets, and share the once-per-name cache with them, so an org secret and a repo secret with the same name get the same value in one apply
  • Changing only the repos list updates access without a prompt. Changing visibility prompts for the value again, GitHub only accepts visibility together with a value
  • The repos list is authoritative: repos dropped from it lose access. Names are resolved to ids after the repos in the config have been reconciled, so an org secret can select a repo created in the same apply
  • Removing a name from orgSecrets deletes the secret. Secrets not listed are left alone
  • An org secret's repo list is one global thing, so keep orgSecrets in exactly one config. If two configs declare the same name, the last apply wins
  • Org secrets cannot be scoped to an environment. For that, declare the name under environments[].secrets on each repo

Ruleset fields

Each entry in rulesets supports:

  • name — required
  • target — "branch" (default) or "tag"
  • enforcement — "active" (default), "evaluate", or "disabled"
  • include / exclude — branch/tag patterns. Defaults to ["~DEFAULT_BRANCH"]. Use "~ALL" to match everything
  • preventCreation: true — block creating matching branches/tags
  • preventUpdate: true — block updating matching branches/tags
  • preventDeletion: true — block branch/tag deletion
  • preventForcePush: true — block force pushes
  • requireLinearHistory: true — require linear commit history (no merge commits)
  • requireSignedCommits: true — require signed commits
  • requirePR: { approvals, dismissStale, codeOwners, lastPushApproval, resolveThreads, requiredReviewers } — require pull requests
  • requirePR.requiredReviewers — see "Required reviewers" below
  • requiredStatusChecks: { strict, checks: [...], doNotEnforceOnCreate } — required CI checks; checks is strings or { context, integrationId }; doNotEnforceOnCreate: true skips enforcing the checks when a branch/tag is created (defaults to false)
  • filePathRestrictions: ["..."] — glob restrictions on which file paths can change
  • requiredWorkflows: [{ path, repositoryId, ref }] — required GitHub Actions workflows
  • doNotEnforceWorkflowsOnCreate: true — skip enforcing requiredWorkflows when a branch/tag is created (defaults to false)
  • mergeQueue — require a merge queue on the branch. true accepts every default, or pass an object to tune it. Branch rulesets only. See "Merge queue" below
  • bypassActors: [...] — entries: { team }, { username }, { app } (GitHub App slug, e.g. "dependabot"), or { type: "OrganizationAdmin" }, each with optional mode: "always"|"pull_request"

Merge queue

mergeQueue requires pull requests to merge through GitHub's merge queue. The queue tests each entry against the tip of the base branch plus everything ahead of it, so it gives the same guarantee as requiredStatusChecks.strict without making authors rebase and re-run CI whenever someone else merges first.

true takes every default:

{ "name": "main", "include": ["~DEFAULT_BRANCH"], "mergeQueue": true }

Or tune it:

{
  "name": "main",
  "include": ["~DEFAULT_BRANCH"],
  "requiredStatusChecks": { "strict": true, "checks": ["ci / build"] },
  "mergeQueue": {
    "mergeMethod": "SQUASH",
    "groupingStrategy": "ALLGREEN",
    "checkResponseTimeout": 60,
    "maxEntriesToBuild": 5,
    "maxEntriesToMerge": 5,
    "minEntriesToMerge": 1,
    "minEntriesToMergeWait": 5
  }
}
  • mergeMethod — "MERGE" (default), "SQUASH", or "REBASE". "MERGE" conflicts with requireLinearHistory, since a merge commit is not linear
  • groupingStrategy — "ALLGREEN" (default) requires every merge commit in a group to pass its required checks; "HEADGREEN" requires only the commit at the head of the group. ALLGREEN is safer and costs more CI
  • checkResponseTimeout — minutes to wait for a required check to report a conclusion before assuming it failed (default 60). Set this above your slowest required check or healthy pull requests get dequeued
  • maxEntriesToBuild — how many queued entries may run checks at once (default 5)
  • minEntriesToMerge / maxEntriesToMerge — group size bounds (defaults 1 and 5)
  • minEntriesToMergeWait — minutes to wait for minEntriesToMerge to be met before merging a smaller group anyway (default 5)

Required status checks must be triggerable by the merge_group event, otherwise they never report against the queue's temporary ref and every entry stalls until checkResponseTimeout elapses:

on:
  pull_request:
  merge_group:

Required reviewers (beta)

requirePR.requiredReviewers lets you require specific teams to approve PRs that touch certain file paths. Each entry has:

  • team — name of an org team that must approve
  • filePatterns — array of fnmatch patterns; the team is required when a PR changes any matching file
  • minApprovals — minimum approvals from that team (default 1; 0 adds the team as a reviewer without requiring approval)

Example: infra team must approve any change to Terraform files or infra/, with two approvals; security team must approve any change under auth/:

{
  "name": "main-protection",
  "include": ["~DEFAULT_BRANCH"],
  "preventForcePush": true,
  "requirePR": {
    "approvals": 1,
    "requiredReviewers": [
      { "team": "infra", "filePatterns": ["**/*.tf", "infra/**"], "minApprovals": 2 },
      { "team": "security", "filePatterns": ["auth/**"] }
    ]
  }
}

GitHub flags this API as beta — the parameter shape may change on their side.

{
  "org": "my-org",
  "presets": {
    "default-rules": [
      {
        "name": "main",
        "preventDeletion": true,
        "preventForcePush": true,
        "requirePR": { "approvals": 1 },
        "bypassActors": [{ "type": "OrganizationAdmin" }]
      }
    ]
  },
  "repos": [
    { "name": "api", "private": true, "rulesets": "$default-rules" },
    { "name": "web", "private": true, "rulesets": "$default-rules" },
    { "name": "docs", "private": false, "rulesets": "$default-rules" }
  ]
}

Lock down a set of public modules

{
  "org": "my-org",
  "presets": {
    "oss-merging": { "squashOnly": true, "deleteBranchOnMerge": true },
    "oss-protection": [
      {
        "name": "main-branch",
        "include": ["~DEFAULT_BRANCH"],
        "preventDeletion": true,
        "preventForcePush": true,
        "requirePR": { "approvals": 1, "dismissStale": true, "lastPushApproval": true }
      }
    ]
  },
  "repos": [
    {
      "name": "module-a",
      "private": false,
      "merging": "$oss-merging",
      "rulesets": "$oss-protection"
    },
    {
      "name": "module-b",
      "private": false,
      "merging": "$oss-merging",
      "rulesets": "$oss-protection"
    },
    { "name": "module-c", "private": false, "merging": "$oss-merging", "rulesets": "$oss-protection" }
  ]
}

Manage org members

{
  "org": "my-org",
  "admins": ["alice", "bob"],
  "members": ["charlie", "dave", "eve"]
}

admins and members are independent. If admins is present, only listed users will be admins. If members is present, only listed users will be members. A role never given is unmanaged. Removing one that state has removes everyone it listed from the org, except those still named under the other role.

Removing someone from the org also removes them from all teams. If that person is still listed in a team config, the next apply will re-add them. Make sure admins/members is the superset of everyone referenced in teams.

Manage org teams

{
  "org": "my-org",
  "teams": [
    {
      "name": "engineering",
      "description": "All engineers",
      "privacy": "closed",
      "members": [
        { "username": "alice", "role": "maintainer" },
        { "username": "bob", "role": "member" }
      ]
    },
    {
      "name": "backend",
      "parent": "engineering",
      "members": [
        { "username": "alice", "role": "maintainer" },
        { "username": "charlie", "role": "member" }
      ]
    },
    {
      "name": "devops",
      "parent": "engineering",
      "members": [{ "username": "dave", "role": "maintainer" }]
    }
  ],
  "repos": [{ "name": "api", "teams": [{ "name": "backend", "permission": "write" }] }]
}

Org teams are reconciled before repos. Parent teams should come before children in the array. Members not in the list are removed. Teams in state but not in config are deleted. Renaming a team will create the new team and delete the old one.

Add individual collaborators to a repo

{
  "org": "my-org",
  "repos": [
    {
      "name": "secret-project",
      "private": true,
      "collaborators": [
        { "username": "alice", "permission": "admin" },
        { "username": "bob", "permission": "write" }
      ]
    }
  ]
}

Only direct collaborators are managed. Org-level implicit access is ignored. Unlisted direct collaborators are removed.

Deploy keys

{
  "org": "my-org",
  "repos": [
    {
      "name": "my-lib",
      "deployKeys": [
        { "title": "ci-deploy", "key": "ssh-ed25519 AAAA... ci@example" },
        { "title": "release-bot", "key": "ssh-ed25519 AAAA...", "readOnly": false }
      ]
    }
  ]
}

Fields:

  • title — required. The identity of the key, like username on collaborators.
  • key — required. The full public key line. Only public material goes in config.
  • readOnly — optional, defaults to true. Set it to false for a key that may push.

Behavior:

GitHub only creates, lists and deletes deploy keys; a key's title, contents and read-only flag are fixed once made. So a key whose contents or readOnly changed is deleted and created again (deploy-key ... replaced). Missing keys are created (deploy-key), and a key octoops made that the config no longer declares is removed (remove-deploy-key). Keys octoops never recorded are left alone, like direct collaborators versus implicit access. GitHub drops the comment from a key and keeps the type and base64, so only those two are compared.

GitHub allows a public key on one repository only. Adding one that is already attached elsewhere fails with an error naming the title; generate a key per repo. For a single key, pass one object instead of a list.

--dry-run diffs config against state without reading the repo's keys, so it shows what's declared rather than what would change.

Minimal repo with just teams and topics

{
  "org": "my-org",
  "repos": [
    {
      "name": "internal-tool",
      "private": true,
      "topics": ["internal", "tooling"],
      "teams": [
        { "name": "platform", "permission": "admin" },
        { "name": "everyone", "permission": "read" }
      ]
    }
  ]
}

npm trusted publishing

{
  "org": "my-org",
  "repos": [
    {
      "name": "my-module",
      "private": false,
      "npm": {
        "package": "my-module",
        "trustedPublishing": {
          "workflow": "publish.yml",
          "environment": "npm"
        }
      }
    }
  ]
}

Sets up npm trusted publishing so GitHub Actions can publish via OIDC without npm tokens. If the package doesn't exist on npm yet, a placeholder 0.0.0 is published first. package defaults to the repo name if omitted, or to <scope>/<repo-name> if scope is set. Requires interactive npm authentication on first run. A one-time password only buys npm a few minutes of access, so when it runs out mid-apply and a command comes back 401, octoops reruns that command on the terminal for npm to prompt again and then carries on, instead of bailing.

{
  "npm": { "scope": "@my-org", "trustedPublishing": { "workflow": "publish.yml", "environment": "npm" } }
}

…makes the package name default to @my-org/<repo-name>. The leading @ is optional; octoops adds it if missing. Defining package explicitly overrides scope.

For repos that publish multiple packages, use an array:

"npm": [
  { "package": "my-module", "trustedPublishing": { "workflow": "publish.yml", "environment": "npm" } },
  { "package": "my-module-cli", "trustedPublishing": { "workflow": "publish.yml", "environment": "npm" } }
]

A single package can also be published by more than one workflow — trustedPublishing takes an array too:

"npm": {
  "package": "my-module",
  "trustedPublishing": [
    { "workflow": "publish.yml", "environment": "npm" },
    { "workflow": "nightly.yml", "environment": "npm" }
  ]
}

Don't mix the two up: npm as an array means several packages from one repo, trustedPublishing as an array means several workflows publishing one package. A bare object is shorthand for a one-element list, so existing configs keep working untouched. npm allows up to 10 publishers per package. Each package in the list is diffed against state on its own, so editing or adding one entry only touches that package; the others are not listed, re-authenticated or re-reconciled. A package removed from the list (or the whole npm block) has the publishers state tracks for it revoked (npm-untrust); maintainers and deprecation are left as they are.

Publishers reconcile as a set keyed on (repository, workflow, environment). Declared but missing gets added (npm-trust), present but undeclared gets revoked (npm-untrust), and anything already matching is left alone. A missing environment counts as none on both sides, so undefined, null and "" never churn. Adds run before revokes, so an interrupted apply leaves a package with too many publishers rather than none. Duplicate entries are collapsed before planning.

Only publishers this entry could have created are reconciled — GitHub publishers bound to this repo. One pointing at a different repo, or from another provider such as GitLab, is left alone rather than revoked.

An empty trustedPublishing list revokes every publisher this repo has on the package. Removing the key does the same for a package the state tracks, and leaves a package it never set up alone.

Needs npm 11.15.0 or newer. Earlier versions have no --allow-publish flag on npm trust github, so every add fails with EUSAGE.

--dry-run prints each declared publisher without reading the registry, so it shows what's declared rather than what would change.

Expiry and renewal

npm deletes a trusted publisher that hasn't published anything within two days of being created. Since octoops usually sets publishers up well before the first release, it tracks this itself, per publisher. State keeps an npmTrust map per repo, keyed on package name, with one entry per publisher npm lists for it:

"npmTrust": {
  "my-module": [
    { "id": "d99e4715-…", "file": "publish.yml", "environment": "npm", "setAt": "2026-10-12T09:00:00.000Z", "confirmed": false }
  ]
}

id is what npm assigned the publisher, learned by listing again after an apply creates one. setAt is written when a publisher is created. Until it is 12 hours old nothing happens and nothing is fetched. After that, every apply (whether or not the npm block changed) gives the package one unauthenticated read of the public registry:

  • Every version published through a trusted publisher names the publisher config that let it in. A version carrying this publisher's id published after setAt means it has been used. It is marked confirmed (npm-trust-confirmed) and never checked again. A package with a single publisher skips the id match: any trusted publish is its own.
  • Otherwise that publisher alone is revoked and recreated (npm-trust-renew, then npm-untrust/npm-trust for just that one) and its setAt starts over. Siblings keep their ids and clocks. This needs an npm login like any other publisher change. Pass --no-renew to only report (npm-trust-expired) without touching npm; the publisher is then checked again on the next apply. Pass --force-renew to skip the clock: every unconfirmed publisher is checked against the registry right away and recreated unless a publish vouches for it, first-seen ones included. --no-renew still wins when both are given.
  • A trusted publish since the clock started that matches none of the package's ids is reported as npm-trust-unmatched before renewing, so a publisher from another repo or provider publishing here does not pass unnoticed.

So a steady-state apply makes no registry requests at all, and a package costs at most one per window. Twelve hours is well short of npm's two days on purpose: applies can be a day and a half apart and still renew in time. The price is a recreate on every apply past that age, and only until the publisher's first release confirms it.

To see every publisher and where it stands, without touching npm or the registry:

octoops npm-trust config.json                 # every publisher, with its clock
octoops npm-trust config.json --unconfirmed   # only those still waiting on a trusted publish

It takes a manifest with includes as well, and reads the same state an apply would. A confirmed entry means the registry has seen a publish through that publisher after setAt, which npm never expires. It does not mean the publisher still exists: one revoked by hand on npm, or revoked and recreated, looks the same from the outside. Only npm trust list can tell, so if that might have happened, edit the npm block (or seed the repo) to force a resync.

Publishers seen for the first time without a setAt, such as state from before this feature or a fresh seed/resync, are confirmed if any version at all was published through them. If none was, the clock starts at that apply (npm-trust-track), so a publisher that already expired is recreated within two days instead of failing the next release. Archived repos are skipped: their workflow can't run, so there is nothing to confirm. Deprecated packages (deprecated set to a message or true) are not renewed either: a publisher that never published is left to expire rather than recreated every window for a package nobody means to release again. Its entry keeps its clock, so lifting the deprecation makes it overdue at once and the next apply checks and renews it. Removing a workflow from trustedPublishing revokes that publisher on npm and drops its entry. Removing trustedPublishing from a package still in the state revokes every publisher of this repo on npm (npm-untrust, needs an npm login) and drops the package from the state.

State from before per-publisher tracking (a single setAt/confirmed per package) is carried over: the package clock is handed to each publisher. A package-level confirmation is not: it only said that some publisher of the package had published, so each publisher is proven again through its own id on the next apply, and setAt is backfilled from the first publish that proved it. The same goes for any confirmed entry without a setAt, there is nothing to re-derive the proof from. A package with several publishers needs their ids before it can tell them apart, so its first check lists them on npm (one login, npm-trust-check in a dry run) and then confirms or renews each on its own. seed and resync carry the npmTrust map over since nothing on GitHub can rebuild it.

You can also manage the package's npm maintainer list:

"npm": {
  "package": "my-module",
  "maintainers": ["alice", "bob", "charlie"],
  "trustedPublishing": { "workflow": "publish.yml", "environment": "npm" }
}

Octoops adds anyone in maintainers who isn't already an owner and removes anyone who is an owner but not in the list — except the caller (whoever ran octoops apply). The caller is never removed, even if they're not listed in maintainers; you'll see a npm-keep-self log line. This prevents you from locking yourself out by mistake.

You can also deprecate a package:

"npm": {
  "package": "my-module",
  "deprecated": "Use @my-org/my-module instead"
}
  • deprecated — optional. A string is used as the deprecation message. true uses the default message This package is deprecated. false (or "") clears an existing deprecation. Omit it entirely to leave deprecation unmanaged.

Like every other field, deprecation is only reconciled when the npm block differs from recorded state — a matching re-apply does nothing. When it does run, octoops checks the live registry first and only calls npm deprecate if the current message actually differs (npm-deprecate / npm-undeprecate log lines). If the package isn't on npm yet you'll see a skip-deprecate line.

This also works on archived repos: the npm registry is independent of GitHub's archive flag, so octoops still reconciles deprecation (and other npm state) even when archived: true — deprecating a package while archiving its repo is the common case.

PyPI trusted publishing (OIDC)

{
  "org": "my-org",
  "repos": [
    {
      "name": "my-lib",
      "pypi": {
        "package": "my-lib",
        "trustedPublishing": {
          "workflow": "publish.yml",
          "environment": "pypi"
        }
      }
    }
  ]
}

Fields:

  • package — optional, defaults to the repo name. The PyPI project name.
  • trustedPublishing.workflow — required. The GitHub Actions workflow file that publishes (e.g. publish.yml).
  • trustedPublishing.environment — optional. The deployment environment the workflow uses. Referenced only — octoops does not create it. If you want a protected environment (reviewers etc.), declare it under environments as usual; the pypi block just names it.

Behavior:

PyPI has no API token or CLI to create a trusted publisher — it's configured through a logged-in browser session only. So octoops can't reconcile the PyPI side. Instead, apply prints the exact settings to enter once on PyPI (a pypi-manual log line), pauses until you press enter to confirm you have entered them (ctrl-c aborts the apply), and records the config in state so subsequent applies stay quiet:

pypi-manual my-lib (configure trusted publisher on PyPI)
    Package:      my-lib
    Owner:        my-org
    Repository:   my-lib
    Workflow:     publish.yml
    Environment:  pypi
    Existing project: https://pypi.org/manage/project/my-lib/settings/publishing/
    New project:      https://pypi.org/manage/account/publishing/ (add as a "pending publisher")
Press enter once the trusted publisher is configured on PyPI, ctrl-c to abort:

The pause is skipped on dry runs and when stdin is not a terminal. For a project that already exists on PyPI, add the publisher on its own publishing settings page. For a project that doesn't exist yet, add it as a "pending publisher" on the account page — the first publish then creates the project (no placeholder release needed). For multiple packages from one repo, pass a list of objects instead of one.

Your workflow needs permissions: id-token: write and should use pypa/gh-action-pypi-publish. octoops does not manage the workflow file.

crates.io trusted publishing (OIDC)

{
  "org": "my-org",
  "repos": [
    {
      "name": "my-crate",
      "crates": {
        "package": "my-crate",
        "license": "Apache-2.0",
        "trustedPublishing": {
          "workflow": "publish.yml",
          "environment": "crates"
        }
      }
    }
  ]
}

Fields:

  • package — optional, defaults to the repo name. The crate name.
  • license — the SPDX license expression of the placeholder, required only when the crate doesn't exist yet. crates.io rejects a crate without one.
  • trustedPublishing — the GitHub Actions workflows that publish the crate: a workflow and optional environment, or a list of them for several workflows. crates.io allows up to 5 per crate.

Behavior:

crates.io only takes a trusted publisher for a crate that exists, so a placeholder 0.0.0 is published first if the crate isn't on crates.io yet (crates-publish). Its description is the repo's description and its repository the GitHub repo. The placeholder is published with cargo publish, so cargo must be logged in.

Publishers are then reconciled through the crates.io API as a set keyed on (workflow, environment): declared but missing gets added (crates-trust), present but undeclared gets revoked (crates-untrust), and anything already matching is left alone. Adds run before revokes, so an interrupted apply leaves a crate with too many publishers rather than none. Only GitHub publishers bound to this repo are reconciled; others are left alone. crates.io never expires a publisher, so there is no renewal. A crate removed from the list (or the whole crates block), or one whose trustedPublishing is removed, has the publishers of this repo revoked. The crate itself is left alone.

The API is called with the token cargo publishes with, from CARGO_REGISTRY_TOKEN or cargo login (~/.cargo/credentials.toml). It needs the publish-new scope for placeholders and the trusted-publishing scope for publishers. A token kept by a credential provider such as the macOS keychain can't be read, so pass it in CARGO_REGISTRY_TOKEN instead. For multiple crates from one repo, pass a list of objects instead of one.

--dry-run checks whether each crate exists and prints each declared publisher without reading crates.io's publishers, so it shows what's declared rather than what would change.

Your workflow needs permissions: id-token: write and should exchange its OIDC token with rust-lang/crates-io-auth-action. octoops does not manage the workflow file.

NuGet trusted publishing (OIDC)

{
  "org": "my-org",
  "repos": [
    {
      "name": "my-lib",
      "nuget": {
        "package": "MyOrg.MyLib",
        "owner": "MyOrg",
        "trustedPublishing": {
          "workflow": "publish.yml",
          "environment": "nuget"
        }
      }
    }
  ]
}

Fields:

  • package — optional, defaults to the repo name. The NuGet package ID.
  • owner — required. The nuget.org account that owns the policy, either a user or an organization. A policy applies to the packages its owner owns.
  • trustedPublishing.workflow — required. The GitHub Actions workflow file that publishes (e.g. publish.yml).
  • trustedPublishing.environment — optional. The deployment environment the workflow uses. Referenced only — octoops does not create it. If you want a protected environment (reviewers etc.), declare it under environments as usual; the nuget block just names it.

Behavior:

NuGet has no API token or CLI to create a trusted publishing policy — it's configured through a logged-in browser session only. So octoops can't reconcile the NuGet side. Instead, apply prints the exact settings to enter once on nuget.org (a nuget-manual log line), pauses until you press enter to confirm you have entered them (ctrl-c aborts the apply), and records the config in state so subsequent applies stay quiet:

nuget-manual MyOrg.MyLib (configure trusted publishing policy on NuGet)
    Package:          MyOrg.MyLib
    Policy owner:     MyOrg
    Repository owner: my-org
    Repository:       my-lib
    Workflow:         publish.yml
    Environment:      nuget
    Policies:         Trusted Publishing in the nuget.org account menu, signed in as a member of the policy owner
Press enter once the trusted publishing policy is configured on NuGet, ctrl-c to abort:

The pause is skipped on dry runs and when stdin is not a terminal. A policy can be added before the package exists, so the first publish creates it (no placeholder release needed). A policy owned by an organization stops working while the member who created it is not in the organization, so create it from an account that stays a member. For multiple packages from one repo, pass a list of objects instead of one.

Your workflow needs permissions: id-token: write and should exchange its OIDC token with NuGet/login, passing the nuget.org username of the member who created the policy. octoops does not manage the workflow file.

pub.dev automated publishing (OIDC)

{
  "org": "my-org",
  "repos": [
    {
      "name": "my-lib",
      "pubDev": {
        "package": "my_lib",
        "trustedPublishing": {
          "tagPattern": "v{{version}}",
          "environment": "pub-dev"
        }
      }
    }
  ]
}

Fields:

  • package — optional, defaults to the repo name. The pub.dev package name.
  • trustedPublishing.tagPattern — optional, defaults to v{{version}}. The pattern of the tags whose pushes may publish. pub.dev names no workflow file, only the tags it accepts.
  • trustedPublishing.environment — optional. The deployment environment the workflow must use. Referenced only — octoops does not create it. If you want a protected environment (reviewers etc.), declare it under environments as usual; the pubDev block just names it.

Behavior:

pub.dev has no API token or CLI to enable automated publishing — it's enabled through a logged-in browser session on the package's Admin tab only. So octoops can't reconcile the pub.dev side. Instead, apply prints the exact settings to enter once on pub.dev (a pub-dev-manual log line), pauses until you press enter to confirm you have entered them (ctrl-c aborts the apply), and records the config in state so subsequent applies stay quiet:

pub-dev-manual my_lib (enable automated publishing on pub.dev)
    Package:      my_lib
    Repository:   my-org/my-lib
    Tag pattern:  v{{version}}
    Environment:  pub-dev
    Admin:        https://pub.dev/packages/my_lib/admin (publish the first version by hand if the package does not exist)
Press enter once automated publishing is enabled on pub.dev, ctrl-c to abort:

The pause is skipped on dry runs and when stdin is not a terminal. pub.dev only offers automated publishing for a package that exists, and never deletes a version, so an uploader publishes the first version by hand with dart pub publish. For multiple packages from one repo, pass a list of objects instead of one.

Your workflow needs permissions: id-token: write and should run dart pub publish --force on a tag push, such as through dart-lang/setup-dart. octoops does not manage the workflow file.

Programmatic usage

const { apply, importOrg, seed } = require('octoops')

await apply(config, {
  dry: false,
  statePath: './config.state.json',
  audit: true
})

const config = await importOrg('my-org')
const membersOnly = await importOrg('my-org', { only: ['members'] })

seed(config, { statePath: './config.state.json' })

A state file is written next to the config to track what was last applied. On partial failure, completed steps are saved so the next run picks up where it left off. A state entry alone is not taken as proof the repo exists on GitHub: the first apply that touches a repo checks and records exists: true, so a repo that was never created (for example after a failed first apply) is still created.

Note

This was written by a silly robot so be aware of mistakes.

License

Apache-2.0