Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
34a4a90
Document FilOzone GitHub management operations
beck-8 Nov 26, 2026
2bcc7ff
Merge branch 'master' into beck-8/filozone-runbook
filozone-mgmt-read-write[bot] Nov 29, 2026
011a561
Merge branch 'master' into beck-8/filozone-runbook
filozone-mgmt-read-write[bot] Dec 1, 2026
0a4858f
Merge branch 'master' into beck-8/filozone-runbook
filozone-mgmt-read-write[bot] Dec 2, 2026
2cec3b9
Merge branch 'master' into beck-8/filozone-runbook
filozone-mgmt-read-write[bot] Dec 2, 2026
f36df06
Merge branch 'master' into beck-8/filozone-runbook
filozone-mgmt-read-write[bot] Dec 2, 2026
b62b0c6
Refine FilOzone GitHub management operations guide
beck-8 Dec 2, 2026
dd9366a
Document 1Password storage for bootstrap state
beck-8 Dec 2, 2026
b586113
Clarify FilOzone state recovery and operator steps
beck-8 Dec 2, 2026
02be484
Shorten S3 state recovery guidance
beck-8 Dec 2, 2026
2b973ba
Retire the automatic upstream upgrade workflow
beck-8 Dec 2, 2026
18eeed5
Remove the one-time FilOzone migration note
beck-8 Dec 2, 2026
ebcbb0e
Keep the observed FilOzone rebuild time
beck-8 Dec 2, 2026
4c0c596
Document FilOzone organization member removal
beck-8 Dec 2, 2026
1e8a748
Explain why there are three environments and fix the README FAQ
BigLep Dec 3, 2026
27054a8
Address review: clearer terms, linked workflows, bootstrap state in S3
BigLep Dec 3, 2026
a76c722
Fix accuracy issues found in the Codex review
BigLep Dec 3, 2026
1290feb
Clarify FilOzone Terraform state migration and recovery
beck-8 Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/upgrade.yml

This file was deleted.

26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<div align="center">
# FilOzone GitHub Management

![Management Banner](https://github.com/pl-strflt/github-mgmt-template/assets/6688074/15b2101a-149a-4556-a1b5-497b50d77813)
This repository manages FilOzone's GitHub organization settings through pull requests. The FilOz team maintains it from the [ipdxco/github-as-code template](https://github.com/ipdxco/github-as-code), using a similar setup in [filecoin-project/github-mgmt](https://github.com/filecoin-project/github-mgmt).

# GitHub Management as Code
## Request an access change

A robust template for managing GitHub configurations as code via Pull Requests. Designed with the effective administration of multiple medium to large-sized GitHub organizations in mind.
1. Edit the relevant membership, team, or repository collaborator in [`github/FilOzone.yml`](github/FilOzone.yml).
2. Open a PR to `master` and explain what access is needed and why. The [github-mgmt stewards](https://github.com/orgs/FilOzone/teams/github-mgmt-stewards) are requested to review it. Check any formatting commits and review the Terraform plan on the PR.
3. After approval and merge, [Apply](.github/workflows/apply.yml) applies the reviewed plan. Verify the result in GitHub after the Apply run succeeds.

</div>
To request that someone be removed from FilOzone, open a PR to revoke their team memberships and direct repository access. Keep their entry in `members` and add a comment explaining that an organization owner will remove them in GitHub. See the [member removal procedure](docs/INFRA_ADMIN.md#remove-a-member-from-filozone) for the steps after merge.

## Importance of Access Control
See [HOWTOS](docs/HOWTOS.md) for configuration examples and the [infrastructure admin guide](docs/INFRA_ADMIN.md) for operating the workflows and Terraform backend.

**NOTE**: Possessing write access to the GitHub Management repository can equate to having administrative privileges over the organizations managed by that repository. Please exercise caution and ensure proper access control measures.
## Importance of access control

## Dive Deeper
Write access to this repository can affect administrative settings across the organization. Grant it with the same care as other organization administration access.

- Learn more about [what GitHub Management is and how it works](docs/ABOUT.md).
- Get started with [setting up GitHub Management](docs/SETUP.md).
- Uncover [how to effectively utilize GitHub Management](docs/HOWTOS.md).
## Why is it called github-mgmt?

## Active Users

A broad range of diverse organizations are already leveraging our GitHub Management solution via Pull Request Workflow. You can find a comprehensive list of these organizations on our [GitHub Management Router repository](https://github.com/pl-strflt/github-mgmt-router). This list showcases the versatility and effectiveness of our GitHub Management system. Our solution can be tailored to meet your unique requirements, driving efficiency and streamlined GitHub organization management.
[ipdxco/github-as-code](https://github.com/ipdxco/github-as-code) grew out of [filecoin-project/github-mgmt](https://github.com/filecoin-project/github-mgmt). github-mgmt was the original name, and it's the one that has stuck in the Filecoin community.
7 changes: 2 additions & 5 deletions docs/HOWTOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ I push my changes to a new branch and create a PR. An admin reviews the PR and m

### ...synchronize GitHub Management with GitHub?

Run the `Sync` workflow from `master` using **Actions → Sync → Run workflow**.

`Sync` imports the current GitHub configuration into the FilOzone Terraform state in S3 and force-pushes the updated YAML to `master`.
`Sync` imports the current GitHub configuration into the FilOzone Terraform state in S3 and force-pushes the updated YAML to `master`. Follow [Sync from GitHub](INFRA_ADMIN.md#sync-from-github) in the admin guide to run it.

### ...upgrade GitHub Management?

- Run `Upgrade` GitHub Action workflow
- Merge the pull request that the workflow created once the `Comment` check passes and you verify the plan posted as a comment - *the plan should not contain any changes*
Use the [reviewed PR process for upstream upgrades](INFRA_ADMIN.md#upgrade-from-upstream).

### ...remove resources from GitHub Management state?

Expand Down
121 changes: 121 additions & 0 deletions docs/INFRA_ADMIN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# FilOzone github-mgmt infrastructure admin guide

This guide is for FilOz maintainers operating github-mgmt. See the [README](../README.md) to request access, [ABOUT](ABOUT.md) for the resource model, and [SETUP](SETUP.md) for installation details.

## Terraform state

[Plan] previews proposed changes. [Apply] runs after a merge to `master`, regenerates the plan, and applies it when it matches the reviewed plan. [Sync] reads FilOzone's GitHub settings into the Terraform state and updates the YAML.

| Backend | Value |
| --- | --- |
| FilOz AWS account and region | `941641221830`, `us-east-1` |
| Versioned bucket and Terraform workspace | `filoz-github-mgmt-filozone`, `FilOzone` |
| Organization state object | `org/FilOzone/terraform.tfstate` |
| Organization state lock object | `org/FilOzone/terraform.tfstate.tflock` |
| Bootstrap state object | `bootstrap/terraform.tfstate` |
| AWS OIDC roles | `filoz-github-mgmt-filozone-ro` and `filoz-github-mgmt-filozone-rw` |

The [Terraform state backend](../terraform/terraform_override.tf) stores the state used by the workflows. The [Terraform bootstrap](../terraform/bootstrap/aws.tf) manages the bucket and IAM roles using its own state and lock in the same bucket. The workflow roles' policies only cover the FilOzone and default-workspace state objects and their lock files, not `bootstrap/terraform.tfstate`, so the workflows can't read or change the bootstrap state.

To change the bucket or roles, use your MFA-backed AWS session to run `terraform -chdir=terraform/bootstrap init` and `terraform -chdir=terraform/bootstrap plan`. If the plan proposes creating the existing bucket or IAM roles, check the bootstrap backend and state before applying. Keep both state files private. [Terraform state security](https://developer.hashicorp.com/terraform/language/manage-sensitive-data#state-security-best-practices)

## GitHub Actions environments

The [read-only App](https://github.com/organizations/FilOzone/settings/apps/filozone-mgmt-read-only) and [read-write App](https://github.com/organizations/FilOzone/settings/apps/filozone-mgmt-read-write) authenticate calls to GitHub. Their IDs, installation IDs, and PEM files are stored as [environment secrets](https://github.com/FilOzone/github-mgmt/settings/environments). Jobs that use S3 request temporary AWS credentials through [OIDC](https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws).

| Environment | Allowed branches | GitHub App secrets | AWS access | Jobs |
| --- | --- | --- | --- | --- |
| [`read`][read] | Any | `RO_GITHUB_APP_*` | Read-only role for Plan, Comment, and Fix | [Plan] (`plan`, `comment`), [Fix] (`fix`), [Apply] (`prepare`) |
| [`write`][write] | `master` | `RW_GITHUB_APP_*` | Read-write role for Apply, Sync, and Clean | [Apply] (`apply`), [Sync] (`sync`), [Clean], [Labels] |
| [`push`][push] | `master` | `RW_GITHUB_APP_*`, and `RO_GITHUB_APP_*` for [Clean Up] | None | [Sync] (`push`), [Fix] (`push`), [Update], [Clean Up] |

Why three environments:

- `read` runs on PRs, before the change is reviewed, so it allows any branch and gets only the read-only App and the read-only state role. An unmerged PR can't change FilOzone's GitHub settings or the Terraform state. On PR events, [Plan] and [Fix] run the base branch workflow and use the PR's `github/` directory as input.
- `write` changes FilOzone's GitHub settings and the Terraform state. Only workflows running from `master` can use it, and the normal reviewed-PR flow controls what reaches `master`, so in practice only reviewed and merged code gets the read-write App and the state writer role. The read-write AWS role trusts only this environment.
- `push` commits generated changes back to this repository (formatted YAML, Sync results, updated PR branches). It needs the read-write App to push, but not the Terraform state, so it has no AWS role. [Fix]'s `push` job runs on PR events and pushes formatted YAML to the PR branch, which is another reason to keep state access out of `push`.

The App secrets exist only in these environments, so a job without `environment:` gets no App credentials.

## Apply access changes

- Review the full plan from [Plan] before merging. For a long plan, open **Plan → Comment → Show terraform plans**. After merge, check that the **Terraform Apply** step of [Apply] succeeded and verify the result in GitHub.
- Wait for [Apply] and [Update] to finish before merging the next PR. [Update] attempts to refresh eligible PR branches. Refresh any skipped or conflicting branch and review its new plan. [Apply] stops if the merged commit's plan differs from the reviewed plan.
- github-mgmt can't remove organization members or delete repositories: `prevent_destroy` blocks both ([Terraform resources](../terraform/resources.tf)). Removing a member or deleting a repository can't be cleanly undone, so a deleted YAML line or a typo must not be able to do it. An org owner does it in GitHub instead; see [Remove a member from FilOzone](#remove-a-member-from-filozone). For a repository, prefer archiving; if it must be deleted, an org owner deletes it in GitHub and a maintainer runs [Sync]. Normal PRs can remove team memberships and direct collaborator grants.
- GitHub prevents changes to collaborators and teams on archived repositories. The YAML for an archived repository is reduced to `archived: true`, and Terraform uses the existing state for its grants. To change a grant, unarchive the repository in one PR and check that [Apply] succeeded and the grants are back in the YAML, then change the grant in a separate PR. Re-archive after the access change has applied if the repository should stay archived. [GitHub archive behavior](https://docs.github.com/en/repositories/archiving-a-github-repository/archiving-repositories) · [Terraform locals](../terraform/locals.tf) · [Fix logic](../scripts/src/actions/shared/toggle-archived-repos.ts)
- Some settings can't be changed through github-mgmt. [Terraform overrides](../terraform/resources_override.tf) tell Terraform to ignore changes to them on existing teams, repositories and branch protections, so editing them in the YAML has no effect, and [Sync] leaves them out of the YAML. Change them in GitHub instead. Examples: a team's description, parent team and privacy; a repository's description, topics, homepage, default branch, the four allow-merge toggles, and issues, projects, wiki and Pages settings. The override file is the full list.

### Remove a member from FilOzone

An org owner could simply remove the person in GitHub and run [Sync]. We use a PR first anyway: it records who asked for the removal and why, gives a place to discuss it, and removes the person's team memberships and direct repository grants through the normal reviewed flow.

1. Open a PR that removes the person's team memberships and direct grants on repositories, and explains who requested the removal and why. Keep their entry in the `members` section and add a comment saying an org owner will remove them in GitHub.
2. After the PR merges, verify that [Apply] succeeded and that GitHub shows the team memberships and direct grants were removed.
3. A FilOzone org owner selects the member on the [People](https://github.com/orgs/FilOzone/people) page, chooses **Remove from organization**, and confirms the removal. [GitHub member removal](https://docs.github.com/en/organizations/managing-membership-in-your-organization/removing-a-member-from-your-organization)
4. A maintainer runs [Sync](#sync-from-github) from `master`. Check that the **Sync (FilOzone)** and **Push** jobs succeed and that the member no longer appears in `github/FilOzone.yml`.

## Sync from GitHub

[Sync] is scheduled for Sundays at 00:00 UTC. For a manual run, open [Sync in Actions](https://github.com/FilOzone/github-mgmt/actions/workflows/sync.yml) and select **Run workflow** on `master`. Leave `workspaces` blank or enter `FilOzone`. Keep `lock=true` and `refresh=false`. This setting skips the optional pre-import refresh; [Sync] still refreshes the Terraform state after importing.

Wait for running [Apply], [Sync] and [Clean] runs to finish, and don't merge PRs while [Sync] runs. Its **Push** job favors the sync branch when resolving merge conflicts and uses `git push --force` when publishing the result. Verify that the **Sync (FilOzone)** and **Push** jobs succeeded and review what reached `master`. The [`.sync` file](../.sync) records the run ID.

## Recover or rebuild the organization state

Use these steps for `org/FilOzone/terraform.tfstate`. To recover `bootstrap/terraform.tfstate`, restore a known-good version of that object and verify it with a bootstrap plan.

1. Pause unrelated merges. Disable [Apply in Actions](https://github.com/FilOzone/github-mgmt/actions/workflows/apply.yml) (**⋯ → Disable workflow**) and let running [Apply], [Sync] and [Clean] runs finish.
2. If a known-good version is available, copy it to the same key as the new current version. If the state is unreadable and no usable version remains, confirm versioning is enabled and delete the key without a version ID to add a delete marker. This preserves earlier versions and lets [Sync] start empty. If switching backends, merge the backend PR before running [Sync]. [Restore an S3 object version](https://docs.aws.amazon.com/AmazonS3/latest/userguide/RestoringPreviousVersions.html) · [S3 delete markers](https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeleteMarker.html)
3. Run [Sync](#sync-from-github) from `master` and wait for the **Sync (FilOzone)** and **Push** jobs to succeed. The initial FilOzone import took about 20 minutes ([run](https://github.com/FilOzone/github-mgmt/actions/runs/45818396464)).
4. Re-enable [Apply], then check the new state with a small PR and its [Apply] run.

The first plan after a rebuild can show default merge and sign-off values on archived repositories. Check that the repositories remain archived and that the plan contains only those fields; the pinned GitHub provider skips updates to repositories that stay archived ([provider update logic](https://github.com/integrations/terraform-provider-github/blob/v6.6.0/github/resource_github_repository.go#L740-L746)). Review any other changes before merging.

For a failed run that left a lock, see [Recover from a stuck state lock](#recover-from-a-stuck-state-lock).

## Recover from a failed Apply

Don't merge other PRs until this is resolved. Inspect the failed [Apply] run for the merge commit.

- **Credential failure.** Check the AWS role ARN, OIDC trust, and job environment. For a GitHub sign-in failure, check the App ID, installation ID, and PEM secret in the job's environment.
- **Reviewed plan missing.** Check the **Find sha for plan** and **Download reviewed terraform plan** steps. Retry the failed run after fixing the cause and confirming the reviewed plan is still current. A fresh manual dispatch looks for a [Plan] artifact for the selected commit.
- **Plan mismatch, partial Apply, or drift.** [Plan] and [Apply] generate plans with `-refresh=false`, so they compare the YAML with the saved Terraform state. Check the affected settings in GitHub as well. If GitHub has the intended settings, run [Sync] and review the result. If the intended settings are in the YAML, save that version first, run [Sync] to reconcile the Terraform state and YAML with GitHub, then restore the intended settings through a follow-up PR with a fresh plan.
- Resume merging after [Apply] succeeds, the result is verified in GitHub, and [Update] finishes.

## Recover from a stuck state lock

An interrupted run or an expired AWS session can leave a lock behind. Get the lock ID and path from the error. Check for active or queued [Apply], [Sync] and [Clean] runs, and confirm with the other maintainers that the previous lock holder has stopped and no other writer will start during recovery.

From a fresh checkout of `master`, use an MFA-backed AWS session that can read the backend and delete its lock. Check the AWS account with `aws sts get-caller-identity --query Account --output text` and continue for `941641221830`.

```sh
terraform -chdir=terraform init -input=false
terraform -chdir=terraform workspace select FilOzone
terraform -chdir=terraform workspace show
```

Verify the workspace and match the lock path from the error to the state lock object above. Run `terraform -chdir=terraform force-unlock LOCK_ID` with the lock ID from the failure. Keep locking enabled for the retry. If [Sync] was interrupted while importing, rerun it against the same backend and workspace to reuse the saved progress. Check the Terraform state version and the next Actions run to verify recovery. [Terraform lock recovery](https://developer.hashicorp.com/terraform/language/state/locking#force-unlock)

## Rotate GitHub App credentials

1. An App manager opens the App's settings and generates a new private key. Update `RO_GITHUB_APP_PEM_FILE` in both [`read`][read] and [`push`][push], or `RW_GITHUB_APP_PEM_FILE` in both [`write`][write] and [`push`][push], depending on the App being rotated.
2. Verify the new credentials on the affected workflows: [Plan] and [Fix] for `read`, an [Apply] or [Sync] for `write`, and a token-generating job for `push`. Verify the read-only key in `push` on an approved [Clean Up] run; that workflow can update the cleanup branch.
3. In the App's **Credentials → Key pairs** settings, match the old entry by fingerprint and delete it after verifying the replacement. Confirm that the old fingerprint is absent. [GitHub App key management](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/managing-private-keys-for-github-apps#deleting-private-keys)

## Upgrade from upstream

1. Select a commit of [ipdxco/github-as-code](https://github.com/ipdxco/github-as-code) and record its SHA in the PR description.
2. Apply selected upstream changes. Preserve FilOzone's OIDC workflows, Terraform backend and bootstrap, and local documentation. Keep upgrades on the manual PR path.
3. Open a PR and review the workflow and Terraform diffs directly. [Plan] only takes the PR's `github/` directory as input. Review the plan and verify [Apply] after merge.

[Plan]: ../.github/workflows/plan.yml
[Apply]: ../.github/workflows/apply.yml
[Sync]: ../.github/workflows/sync.yml
[Fix]: ../.github/workflows/fix.yml
[Update]: ../.github/workflows/update.yml
[Clean]: ../.github/workflows/clean.yml
[Clean Up]: ../.github/workflows/cleanup.yml
[Labels]: ../.github/workflows/labels.yml
[read]: https://github.com/FilOzone/github-mgmt/settings/environments/15158011219/edit
[write]: https://github.com/FilOzone/github-mgmt/settings/environments/15158017921/edit
[push]: https://github.com/FilOzone/github-mgmt/settings/environments/15157620722/edit
Loading