Skip to content

feat(tf): declare and import devops-cli in tf/github/dan-petty #5325

Open

Description

@dan-petty

Update 2026-11-26 (infra move): No OpenTofu stack declares these settings (ADR 0035).

Here: add the rows for the Pages site, the github-pages environment and the collaborators to devops repos onboard. In dan-petty/infra: the Pages and collaborator keys of the schema, and the devops-cli settings of the template (follow-up). tf/github/ and tf/modules/repository are not paths of this repository.

Follow-up: dan-petty/infra#175.


Problem or Motivation

devops-cli settings exist only in GitHub, so a transfer has no baseline to compare with.

Order 10 of the plan in #5311. The owner approved the plan on 2026-11-13.

Proposed Solution & Architectural Design

Add the module tf/github/modules/repository and repos.yaml with devops-cli. Add import blocks with for_each, the release and github-pages environments and the environment variable, Pages, Actions and workflow permissions, security_and_analysis and the full collaborator set. Add postconditions on data sources for the 'main' ruleset rule types, the environment secret names and the App installations. Start from a draft by -generate-config-out.

Target Subsystem

OpenTofu / Infrastructure as Code

Existing Tool Considered

OpenTofu 1.13.9 (MPL-2.0) with integrations/github 6.13.0 (MIT), exact pins, a lock file and Renovate bumps.

Cost: Build: devops-cli stack and module about 1.5M tokens and 2 days; org stack about 0.8M tokens and 1 day. Keep: about 100k tokens a month. Fix: about 300k tokens for each provider regression. Owner: about 30 min for each import apply. This item is the devops-cli stack and the module: about 1.5M tokens and 2 days.

Acceptance Criteria

  • The PR body shows a plan from the owner token and a plan from the reader App: imports only, and 0 to add, change or destroy.
  • The owner applies the import plan, and nothing changes on GitHub.

Dependencies

#5317, #5318, #5319 and dan-petty/homelab#358; owner decision 4 in #5311. Part of #5311.

Source: #5311

Alternatives check of 2026-11-22: covers.
Tool: integrations/terraform-provider-github (https://github.com/integrations/terraform-provider-github), MIT, last activity 2026-11-19, maintained.
Reason: Searches found the OpenTofu GitHub provider and a settings-file App; the provider already manages repository settings, environments, permissions and collaborators and supports import, so it covers the need and is already in use.

Covers:

  • Repository settings, Pages, Actions and workflow permissions
  • release and github-pages environments with variables
  • security_and_analysis, collaborator set and rulesets
  • Import of existing resources through OpenTofu import blocks

Lacks:

Proposed design

Problem statement

This item was to declare the devops-cli repository in an OpenTofu stack and import its live settings, so that a transfer has a baseline. ADR 0035 (accepted 2026-11-22) amends decisions 1, 4 and 7 of ADR 0026: devops repos onboard owns the repository settings and applies one baseline, the Copier template of dan-petty/infra at a release tag, and OpenTofu keeps only the organization postconditions and the transfer check. The command's rows do not yet cover three settings that this issue names: the Pages site, the github-pages environment and the collaborator set. This item adds those rows and the baseline keys, then records dan-petty/devops-cli in the baseline and proves that its live settings match it, so the transfer has a baseline to compare with.

Acceptance criteria

Requirement: Pages row

devops repos onboard SHALL read the Pages site settings from the baseline github/repository.yaml and write only the keys that differ.

Scenario: Plan a Pages difference

  • WHEN The test tests/github/onboard/test_onboard_pages.py::test_pages_row_plans_only_the_difference runs with a baseline that names build_type: workflow and a live Pages site that answers build_type: legacy.
  • THEN The test asserts that row pages is pending, that --plan sends no write, and that --confirm sends one Pages write that holds build_type alone.

Requirement: github-pages environment row

devops repos onboard SHALL compare the github-pages environment and its branch policy with the baseline and write only a difference.

Scenario: Plan a github-pages branch policy difference

  • WHEN The test tests/github/onboard/test_onboard_environments.py::test_github_pages_environment_plans_only_the_difference runs with a baseline that names the github-pages environment and the branch policy main, and a live github-pages environment with no branch policy.
  • THEN The test asserts that the environment row reports pending for github-pages, that --plan sends no write, and that --confirm writes the main branch policy of github-pages alone.

Requirement: Collaborator row

devops repos onboard SHALL compare each collaborator and permission of the baseline with the live set and write only the entries that differ.

Scenario: Plan a collaborator difference

  • WHEN The test tests/github/onboard/test_onboard_collaborators.py::test_collaborator_row_plans_only_the_difference runs with a baseline that names octocat: maintain and a live set that holds octocat: push and hubot: pull.
  • THEN The test asserts that row collaborators is pending, that --plan sends no write, and that --confirm writes octocat with maintain, removes hubot, and sends no other collaborator write.

Requirement: One owner for each write route

Each write route of the new rows MUST name the command as its owner, and no route SHALL write a setting of another owner.

Scenario: Check the ownership of the new routes

  • WHEN The test tests/github/onboard/test_onboard_routes.py::test_no_route_writes_a_setting_of_another_owner runs over ROUTES with the Pages, environment and collaborator routes.
  • THEN The test asserts that each new route names its owner and that no route matches /orgs/, /transfer, an App installation or a repository secret.

Requirement: devops-cli baseline entry

The Copier template of dan-petty/infra SHALL hold the answers and the settings of dan-petty/devops-cli, including the release and github-pages environments, the Pages settings, the Actions workflow permissions, security_and_analysis and the collaborator set.

Scenario: Plan the devops-cli repository

  • WHEN The owner runs uv run devops repos onboard dan-petty/devops-cli --plan with their own login and the template at a release tag that holds the entry.
  • THEN The command reads every row from the baseline, reports no not readable row and no failed row, and exits 1 only with pending rows.

Requirement: Owner apply

The owner MUST apply the baseline with their own login, and a second run on the onboarded repository SHALL send no write and exit 0.

Scenario: Apply the devops-cli baseline

  • WHEN The owner runs uv run devops repos onboard dan-petty/devops-cli --confirm, then runs uv run devops repos onboard dan-petty/devops-cli --plan.
  • THEN The first run ends each row present or applied, and the second run exits 0 with no pending row.

Existing Tool Considered

The tool is integrations/terraform-provider-github (https://github.com/integrations/terraform-provider-github), MIT, maintained. The alternatives check of 2026-11-22 in the issue body gives it the verdict covers, and its block is the record of what the provider covers and lacks. The item adopts the provider and builds no replacement for it. ADR 0035 keeps OpenTofu for the organization postconditions and the transfer check and gives the repository settings of this item to devops repos onboard with the Copier baseline of dan-petty/infra, so this item extends that command and the baseline instead of declaring an OpenTofu resource; the block of the alternatives check applies only to the OpenTofu that remains.

Key questions

  • The alternatives check found that https://github.com/integrations/terraform-provider-github covers this item. Adopt the tool, or keep the item and give the reason.: Adopt integrations/terraform-provider-github, and apply ADR 0035 to this item: the provider stays for the OpenTofu that keeps the organization postconditions and the transfer check, and the repository settings of devops-cli go to devops repos onboard with the Copier baseline of dan-petty/infra. The item builds no replacement for the provider and declares no OpenTofu resource for a repository setting. (best practice) [sources: AGENTS.md:9, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:47]
    • Chosen: Adopt integrations/terraform-provider-github. The alternatives check gives the open, maintained provider the verdict covers, and ADR 0035 keeps it for the organization postconditions and the transfer check.
    • Rejected: Keep the OpenTofu stack that declares the repository settings. ADR 0035 section 6 amends decision 1 of ADR 0026: the shared module and the root stacks hold no repository setting.
    • Rejected: Keep the item and give the reason. No reason holds: the provider is MIT, maintained and already in use for the OpenTofu that remains, and the repository settings have a home in the command.
  • Where do the repository settings of dan-petty/devops-cli live now?: In the Copier baseline github/repository.yaml of dan-petty/infra, rendered at a release tag and applied by devops repos onboard. No OpenTofu stack, import block or data-source postcondition holds a repository setting. (best practice) [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:40, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:49, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:65, docs/repos/onboard.md:36, docs/adr/0032-infrastructure-templates-live-in-four-homes.md:69]
    • Chosen: The command with the Copier baseline of dan-petty/infra. ADR 0035 decision 1 gives the command the repository settings with one baseline in infra at a release tag, and ADR 0032 homes the template in infra.
    • Rejected: An OpenTofu stack with import blocks. ADR 0035 section 6 amends decision 1 of ADR 0026, so the module and the stacks hold no repository setting.
    • Rejected: Both the command and OpenTofu. Two copies of one setting drift, and ADR 0035 decision 2 forbids an OpenTofu resource that writes a setting the command owns.
  • Which settings that this issue names does devops repos onboard not cover?: The Pages site settings, the github-pages environment and the collaborator set. The rows of the command are 0 to 15, and none of them reads Pages, a second environment or a collaborator; the baseline schema names repository, vulnerability_alerts, private_vulnerability_reporting, immutable_releases, code_scanning_default_setup, actions_workflow_permissions, rulesets and environments. [sources: docs/repos/onboard.md:44, docs/repos/onboard.md:61, tests/support/github_repository.py:55]
  • How should the change cover the Pages site, the github-pages environment and the collaborator set?: Add one row for each to devops repos onboard, with the keys in the baseline and in the schema of the template, because ADR 0035 gives the command the repository settings and its driver is that a repository gets each setting from one command run and no web UI step where GitHub has an API. The Pages row reuses src/devops_cli/github/pages.py, which already reads the build type, the branch, the path, the custom domain and the HTTPS setting. (best practice) [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:18, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:40, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:43, docs/repos/onboard.md:42, src/devops_cli/github/pages.py:22]
    • Chosen: Extend devops repos onboard with three rows. ADR 0035 gives the repository settings to the command; src/devops_cli/github/pages.py already reads the Pages site, and each write route of the command names its owner.
    • Rejected: Leave the three settings to a person in the GitHub UI. A transfer would then have no baseline for them, and ADR 0035 decision 1 aims at no web UI step where GitHub has an API.
    • Rejected: Keep an OpenTofu resource for the three settings. ADR 0035 decision 2 declares that no OpenTofu resource writes a setting that the command owns.
  • How does the change assert the main ruleset rule types without managing the ruleset?: It does not need a postcondition. ADR 0035 amends decision 7 of ADR 0026: devops repos onboard row 10 reads the live main ruleset, compares it with the baseline and writes only a difference, so the change adds no data-source postcondition and no github_repository_ruleset resource. (best practice) [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:67, docs/repos/onboard.md:56, docs/repos/onboard.md:63]
    • Chosen: Row 10 of devops repos onboard owns the ruleset. ADR 0035 decision 7 amendment gives the command the main ruleset of each repository, and the command writes only a difference.
    • Rejected: A read-only postcondition on a data source. ADR 0035 decision 2 keeps only the organization postconditions and the transfer check in OpenTofu, and this item adds neither.
    • Rejected: Leave the rule types unasserted. Row 10 compares the whole main ruleset with the baseline and reports a difference, so the rule types are asserted.
  • How does the change keep environment secret values out of the baseline, the plan and the state?: The baseline names the secret RELEASE_APP_PRIVATE_KEY and the variable RELEASE_APP_CLIENT_ID only. The command seals the value from the configuration and writes it when it is missing, so no value enters the baseline, the plan, a log or an OpenTofu state. (best practice) [sources: docs/repos/onboard.md:52, AGENTS.md:16, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:22]
    • Chosen: Name the secret and read the value from the configuration. AGENTS.md forbids a secret in the repository, and row 6 checks the secret by name and seals the value with the code of devops gh secret sync --env.
    • Rejected: Hold the value in the baseline. The value would enter the repository, the plan and the log, which AGENTS.md and ADR 0035 forbid.
  • Is build: add OpenTofu 1.13.9 to the devcontainer and runner images #5317 still a dependency?: No. build: add OpenTofu 1.13.9 to the devcontainer and runner images #5317 is delivered: OpenTofu 1.13.9 is on the devtools image and the CI gate reads it from there. [sources: openspec/changes/archive/2026-11-15-5317-add-opentofu-to-the-images/proposal.md, .github/workflows/ci.yml:80, CHANGELOG.md:1404]
  • Are feat(tf): pass flags to tofu; add import, state, show, force-unlock #5318, fix(tf): devops tf drift exits non-zero on drift or a failed check #5319 and dan-petty/homelab#358 still dependencies?: No. This item now writes no OpenTofu resource, so it needs no stack, state namespace or import prerequisite. ADR 0035 keeps only the organization postconditions and the transfer check in OpenTofu, and this item builds neither. (best practice) [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:47, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:49, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:65]
  • Where do the shared module and the root stacks live now?: ADR 0035 amends decision 1 of ADR 0026, so the shared module and the root stacks hold no repository setting. ADR 0032 homes the module in dan-petty/infra as tf/modules/github-repository and the root stacks in dan-petty/homelab as tf/github/, for the organization postconditions and the transfer check. This item adds neither. (best practice) [sources: docs/adr/0032-infrastructure-templates-live-in-four-homes.md:69, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:65, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:49]
    • Chosen: The ADR 0032 homes, for the OpenTofu that remains. ADR 0032 amends the paths of ADR 0026, and ADR 0035 keeps only the organization checks and the transfer check in OpenTofu.
    • Rejected: The ADR 0026 homes in devops-cli. ADR 0032 moves the module to infra and the root stacks to homelab.
    • Rejected: An OpenTofu stack that holds the repository settings. ADR 0035 section 6 amends decision 1 of ADR 0026.
  • Who runs devops repos onboard dan-petty/devops-cli, and when?: The owner, with their own gh login, after dan-petty/infra releases the baseline entry. Agents and the reader App run --plan only. The owner's --confirm run is the apply, and a second --plan run proves that the repository is onboarded. (a person decides) [sources: AGENTS.md:21, docs/repos/onboard.md:71, docs/repos/onboard.md:24, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:40]
  • Who orders the work across dan-petty/devops-cli and dan-petty/infra?: The owner. The template in dan-petty/infra takes the new schema keys and the devops-cli entry at a release tag before the owner's run, because the roadmap enforces no blocker in another repository. (a person decides) [sources: docs/adr/0032-infrastructure-templates-live-in-four-homes.md:81, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:40]
  • Which OpenTofu and provider versions run the OpenTofu that remains, and where is the pin?: OpenTofu 1.13.9 with integrations/github 6.13.0, at exact pins that Renovate updates. The devtools image installs tofu, and the CI gate reads it from the image. This item changes neither pin. [sources: docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:16, .github/workflows/ci.yml:80]

Open questions

  • Who runs devops repos onboard dan-petty/devops-cli, and when? (a person decides)
  • Who orders the work across dan-petty/devops-cli and dan-petty/infra? (a person decides)

Fit

Needs splitting into 2 items:

  1. dan-petty/devops-cli: add the rows for the Pages site, the github-pages environment and the collaborator set to devops repos onboard, with the tests of each row and the row table of docs/repos/onboard.md.
  2. dan-petty/infra: name the three keys in templates/github-repository.schema.json, add the answers and the settings of dan-petty/devops-cli to the Copier template, release a tag, and let the owner run uv run devops repos onboard dan-petty/devops-cli --confirm.

Suspected block

The work waits on dan-petty/infra to release the Copier template with the new schema keys and the dan-petty/devops-cli entry at a tag; dan-petty/infra is outside this roadmap.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/feature
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
    • Scope: none. The title has the scope tf, and .github/labels.yml declares no scope/tf label. Add the label to the file to give the scope to this item.
    • Related: feat(argocd): read the environment from the homelab repo #5134, which asks for a different change. Both configure infrastructure for the devops-cli project, but dan-petty/devops-cli#5134 reads Argo CD environment from a homelab repo while this item declares and imports the GitHub repository in OpenTofu.
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: Searches found that the GitHub provider for Terraform/OpenTofu (integrations/github) is the maintained tool that manages GitHub repository settings as code, and its docs and community answers show the import-block plus -generate-config-out path the issue proposes for importing an existing repository. The issue itself already names this provider (integrations/github 6.13.0) as the existing tool, so it covers the whole need, with OpenTofu providing the plan/apply engine and postconditions.

    The item already names this tool.

    Tool: integrations/terraform-provider-github (https://github.com/integrations/terraform-provider-github)

    • License: MIT
    • Last activity: 2026-11-12
    • Maintained: yes

    Covers:

    • Declares the GitHub repository and its settings as code (github_repository resource)
    • Imports an existing repository and its settings through import blocks
    • Covers environments, environment variables/secrets, Pages, Actions and workflow permissions, security_and_analysis, and the collaborator set
    • Covers rulesets and branch protection for the 'main' branch rule types

    Lacks:

    • The import-block and -generate-config-out machinery is the OpenTofu engine, not the provider, so the generated draft still needs review and edits
    • Provider resources do not by themselves write the issue's postconditions on data sources (ruleset rule types, secret names, App installations)

    Tools considered:

    Searches run:

    • Terraform OpenTofu provider to declare and import GitHub repository settings as code, results: 5
    • integrations/github terraform provider import existing repository settings, results: 5
    • generate terraform config import existing GitHub repository import block generate-config-out, results: 5

    Sources:

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Owner question: Who runs the import plan with the owner token, and who applies it? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  8. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: in-use, tool https://github.com/integrations/terraform-provider-github. A person decides what the new result means for the item.

    Searches (5)

    Tools considered:

    Searches run:

    • OpenTofu provider to manage GitHub repository settings as code, results: 5
    • terraform-provider-github import existing repository environments actions permissions, results: 5
    • probot settings app repository settings.yml as code alternatives, results: 5
    • terraform-provider-github, results: 5
    • registry.terraform.io integrations github provider documentation repository resource, results: 5

    Sources:

  9. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  10. dan-petty commented on Nov 24, 2026

    @dan-petty
    OwnerAuthor

    Adopt the tool: terraform-provider-github. AGENTS.md rule 3 requires using an open tool before building.

  11. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  12. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions