GCSS-1135: Add support for GitHub repository environments - #62
Merged
dev-milos merged 22 commits intoJul 14, 2026
Conversation
Co-authored-by: Ivan Pavlovic <ivan@gr-oss.io>
Co-authored-by: Ivan Pavlovic <ivan@gr-oss.io>
Co-authored-by: Ivan Pavlovic <ivan@gr-oss.io>
Co-authored-by: Ivan Pavlovic <ivan@gr-oss.io>
Co-authored-by: Ivan Pavlovic <ivan@gr-oss.io>
Resolve conflicts by keeping both sides: - repositories.go: Environments + CustomProperties fields - github.go: two-arg ImportRepo(name, cfg) signature + nilIfEmpty helper - import.go: config-driven feature flags - docs/workflows.md: kept main's version (PR deletion reverted) - DEVELOPERS_GUIDE.md: kept custom_properties/high_integrity bullets
- Add jsonschema tags to Environment/DeploymentPolicy structs: environment required, wait_timer bounded 0-43200, policy_type enum - Regenerate repository-config.schema.json so the environments block is a validated property (previously rejected under additionalProperties:false) - Correct wait_timer unit from seconds to minutes in docs and TF examples
The graformer plan summarizer had no case for github_repository_environment_deployment_policy, so those resources rendered as 'unknown type'. Add a branch that shows repo/environment and the branch or tag pattern.
- Move environment resources from the vendored module into the root module; revert modules/terraform-github-repository to upstream (vendored, untouched) - Replace the inline feature-flag map with an explicit feature_github_environments bool in import-config (strict, explicitly (de)serialized) - Fail the import when fetching environments errors (no partial imports); resolveEnvironments and fetchDeploymentPolicies now propagate errors, and unknown reviewer/policy types are rejected - Drop dead code (top-level reviewer resolution + org lookup, map-cast fallback, unused module outputs, IsFeatureEnabled) and remove comments - Scope cleanup: revert tf-apply and Justfile churn, delete ADDING_FEATURES.md and FEATURE_GITHUB_ENVIRONMENT.md, restore the DEVELOPERS_GUIDE High Integrity section, keep DEVELOPERS_GUIDE at repo root
GitHub caps required reviewers at 6 total across users and teams; fail the import instead of producing config Terraform would later reject.
…view comments Replace the hand-rolled deployment-branch-policies request (raw NewRequest/Do, inline structs, and non-functional pagination that never advanced the page) with the typed client.Repositories.ListDeploymentBranchPolicies. Restore the two explanatory comments the reviewer asked to keep.
dev-milos
marked this pull request as ready for review
July 10, 2026 09:39
- Deployment-policy import: importer now stores numeric policy IDs in hidden branch_policy_ids/tag_policy_ids maps (jsonschema:-), root module adds import blocks for branch_policy/tag_policy, promote yq strips the maps, and compare normalisation ignores them (mirrors the ruleset id lifecycle) - fetchDeploymentPolicies: real pagination (per_page=100 + page advance), reusing the typed DeploymentBranchPolicyResponse - Revert WriteRepositoryToYaml to yaml.Marshal (drop unrelated SetIndent(2)) - Reviewer teams stored by slug only (GetSlug), matching the rest of the code - resolveEnvironments: switch on ProtectionRule type (wait_timer vs required_reviewers) to reflect GitHub's mutually-exclusive rule model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for managing GitHub repository environments (deployment protection rules, required reviewers, and deployment branch/tag policies) across the importer, the Terraform provisioning layer, the JSON schema, and the docs.
Continues the work from #28 (whose head lives on a fork we can't push to), rebased on top of current
mainwith all conflicts resolved.What changed
Importer (
feature/github-repo-importer/)Terraform (
feature/github-repo-provisioning/)github_repository_environment, plusgithub_repository_environment_deployment_policyfor branch and tag patterns.modules/terraform-github-repository/), consistent with how every other per-repo sub-resource is already defined there (github_branch_protection,github_repository_collaborator,github_team_repository). The root module passesenvironmentsin and wiresimportblocks that addressmodule.repository[...].github_repository_environment.environment[...].data.github_team/data.github_user.Feature flag
Enable environment import by setting a flat top-level key in
config/import-config.yaml:(The flags are collected via a
yaml:",inline" map[string]bool, so they are flat keys — not a nestedfeatures:block.)YAML configuration structure
JSON schema
Environment/DeploymentPolicystructs carryjsonschematags:environmentrequired,wait_timerbounded0..43200,policy_typerestricted to the enumprotected_branches | selected_branches_and_tags..schemas/repository-config.schema.jsonsoenvironments:is a recognized, validated property (underadditionalProperties: falsethe block would otherwise be rejected at validation time).Known limitations
References