GitHub organizations
What factory init --org does on GitHub for an organization, and what to
do when an organization's secrets do not reach a repository.
What the factory uses it for
One setup that every repository of the organization shares: a GitHub App, the Claude token, a preset of settings, a board, and a rule that requires "Review verdict" before a merge. A developer then sets a repository up with one command, and the repository reads the organization's secrets.
You need
An owner of the organization, with the GitHub CLI signed in, Claude
Code, and the factory command
(Set an organization up, once).
factory init --org needs three permissions for the GitHub CLI that a
plain sign-in lacks: admin:org, project, and workflow. When one is
missing, its first question is whether to open your browser so you can
grant it.
Set it up
An owner runs factory init --org once, as
Set an organization up, once
says.
What setup adds
What factory init --org adds,
once, for every repository of the organization. The table, and the
commands on this page, use acme as the example organization: write
your own organization's name in its place. No command takes these
out: Removing it
lists them in the order to delete them.
What factory init --org adds |
Where to find it |
|---|---|
| The GitHub App "Software Factory for acme", registered by the organization and installed on the repositories its owner chose | The organization's Settings, Developer settings, GitHub Apps |
The secret FACTORY_APP_PRIVATE_KEY, the variable FACTORY_APP_CLIENT_ID, and the secret CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_API_KEY, each for every repository |
The organization's Settings, Secrets and variables, Actions |
The repository acme/factory-config, with factory-preset.yaml, .github/workflows/factory-poller.yml, and a README.md |
Among the organization's repositories |
The property software-factory, with the values on and off, which the first workflow run after a repository's setup merges sets to on for it |
The organization's Settings, Custom properties |
The rule "Software factory", which requires "Review verdict" before a merge to the default branch of each repository whose property is on |
The organization's Settings, Rules. Not on GitHub's Free plan, which has no such rule |
| A board, or whichever of the factory's columns and fields the board the owner chose still lacked | The organization's Projects |
Tokens and secrets
The App's private key is the secret FACTORY_APP_PRIVATE_KEY, its
client ID the variable FACTORY_APP_CLIENT_ID, and the Claude token the
secret CLAUDE_CODE_OAUTH_TOKEN, or an API key as ANTHROPIC_API_KEY,
each stored for every repository (What setup adds).
Claude Code says how
an owner replaces the Claude token.
Replacing the App's key
For an owner of the organization, when the key may have leaked. The
GitHub CLI needs the admin:org permission for step 2, which
gh auth refresh -s admin:org grants.
-
On GitHub, open the organization's Settings, Developer settings, GitHub Apps, then the App's own page, and press "Generate a private key". GitHub downloads the key as a
.pemfile. -
Store it in place of the old one, with your organization's name and the file's:
gh secret set FACTORY_APP_PRIVATE_KEY --org acme --visibility all < FILE.pemIf you had narrowed the secret to chosen repositories, write
--repos NAME,NAMEin place of--visibility all, so it stays narrowed. -
Delete the old key on the App's page, then delete the file.
It worked when a build you start with factory build N, for a
ticket that is ready, gets past the step "Sign in" of its Prepare job. A
wrong key fails the run at that step.
What the factory can and cannot do there
Each job that needs a token makes one from the App's key, and the token
lasts an hour. It reaches only the repositories the App is installed on,
which are the ones the owner chose, and a session's token can't change a
workflow file or set a repository's properties. The rule that requires
"Review verdict" applies only to a repository whose software-factory
property is on (What setup adds).
Limits that come from GitHub
- An organization is set up on github.com only. GitHub Enterprise
Server is not supported: its servers cannot call the factory's
workflows on github.com.
factory init --orgrefuses any other address. - Dependabot's pull requests do not merge themselves under the App, as
set up. The job that turns auto-merge on for one reads Dependabot's
secrets, not the Actions ones, and
factory init --orgstores the App's key for Actions alone. An owner who wants it makes a new key, as Replacing the App's key shows, and stores it a second time for Dependabot, with--app dependabotadded to that section'sgh secret setline. - A build's commits under the App are not signed, so GitHub shows no "Verified" on them.
- The organization-wide rule is untested, since it needs GitHub's
Team plan. The rest of
factory init --orghas run once, in an organization on the Free plan.
On GitHub's Free plan
GitHub Free shares an organization's secrets only with its public
repositories, and has no organization-wide rules. The Plan row, in the
list factory init --org prints first, headed Found, says when the
organization is on it. On that plan, factory init --org makes
factory-config a public repository, so anyone can read the shared
settings in it. What follows differs for the organization's public and private
repositories:
-
A public repository gets the review and builds in the cloud. There is no organization-wide rule, so once its setup merges, an admin of that repository runs
factory initagain, which requires "Review verdict" there. The command's closing lines list that as a third step:3. Once that pull request merges, an admin of the repository runs factory init there again, to require "Review verdict". GitHub Free has no organization-wide rules. -
A private repository can't use a preset that turns on a board, the review, or builds that start from the board, since the plan does not share the organization's secrets with it.
factory initthere stops, changes nothing, and names them:✗ The presets turn on a board, the review, and builds that start from the board. They need acme's secrets, and GitHub Free does not share them with a private repository.Make the repository public, or move the organization to a paid plan, and run
factory initagain. To build only on your machine, run it and leave that preset unchecked. The presetfactory init --orgwrites turns on all three.The plan has no branch rules for a private repository either, so "Review verdict" cannot be required there. Where such a preset was already followed,
factory doctorshows a line for each:✗ CLAUDE_CODE_OAUTH_TOKEN is stored for acme, and GitHub Free does not share it with a private repository: make the repository public, or move acme to a paid plan - "Review verdict" cannot be required here: GitHub Free has no branch rules for a private repository
When something goes wrong
When a later release of the factory needs a new permission for the App, GitHub shows a request to review beside the App, in the organization's Settings, GitHub Apps. An owner accepts it.
When the organization's secrets do not reach you
You need an owner of the organization for this. If init stopped, send them what it printed, which lists only what your repository lacks:
✗ The presets turn on a board, the review, and builds that start from the board. They need acme's secrets, and those do not reach acme/web.
An owner of acme gives acme/web access to each of these, under "Repository access". Then run factory init again.
Secrets: FACTORY_APP_PRIVATE_KEY, and CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY
https://github.com/organizations/acme/settings/secrets/actions
Variable: FACTORY_APP_CLIENT_ID
https://github.com/organizations/acme/settings/variables/actionsIf it went on instead, it listed nothing, and said that the review and
builds in the cloud stay off until the organization's secrets reach your
repository. Send the owner the lines above from "Secrets" on, with your
organization's name in place of acme in the two addresses, and your
repository's name.
On those two pages the owner opens each secret and the variable, and under "Repository access" picks a choice that includes your repository, such as all repositories. Of the two names for what pays for Claude, only the one the organization stored is there. If one is missing from the page, the owner first sets the organization up.
It worked when the Organization row says the app's key and the
Claude token are stored, once you run factory init again.
If the owner keeps the secrets from your repository on purpose, you have two choices:
- Build only on your machine. Run
factory initand leave the presets that turn those parts on unchecked. If.claude/factory.yamllists one underpresets, take its line out first. It worked when init asks "Go ahead?". - Store tokens on the repository in place of the organization's
secrets. You need two, a GitHub token as
FACTORY_BOARD_TOKENand a Claude token asCLAUDE_CODE_OAUTH_TOKEN, and neither of the App's values. Secrets says how to make each, and the command that stores it. It worked whenfactory initasks "Go ahead?" with the presets checked.
By hand
Only factory init --org sets an organization up. The two tasks below
are done on GitHub's site instead.
Limiting who can use the App's key
- To install the App only on chosen repositories, open the organization's Settings, GitHub Apps, and the App's "Configure" page, and change its repository access.
- To narrow each secret to chosen repositories, open the organization's Settings, Secrets and variables, Actions. To give a repository access again, pick a choice that includes it under "Repository access".
Taking the App out
In the organization's Settings, under GitHub Apps, uninstall the App
whose name starts "Software Factory for". Then, under Developer settings,
GitHub Apps, delete it. Do this only once each repository has had
factory remove run and merged, as
Taking an organization's setup out
orders the steps.