Skip to content

feat: add new gh-files-set module#970

Open
frmadem wants to merge 41 commits intomainfrom
feat/969-poc-gh-files-set
Open

feat: add new gh-files-set module#970
frmadem wants to merge 41 commits intomainfrom
feat/969-poc-gh-files-set

Conversation

@frmadem
Copy link
Contributor

@frmadem frmadem commented Mar 8, 2026

solves #969

@frmadem frmadem requested a review from a team as a code owner March 8, 2026 19:43
@frmadem frmadem linked an issue Mar 8, 2026 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Terraform module (modules/gh-files-set) intended to manage a set of files in GitHub repositories (issue #969), and wires it into the repo’s release automation configuration.

Changes:

  • Added new gh-files-set Terraform module using github_repository_file to manage multiple files via a single config object.
  • Added module docs scaffolding (terraform-docs config + header/footer content) and a basic example YAML input.
  • Registered the new module package in release-please-config.json.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
release-please-config.json Registers modules/gh-files-set as a release-please package.
modules/gh-files-set/main.tf Implements managed vs “user-managed” GitHub repository files.
modules/gh-files-set/variables.tf Defines the config input schema + validations.
modules/gh-files-set/outputs.tf Exposes a list of user-managed file paths.
modules/gh-files-set/versions.tf Declares GitHub provider requirement (missing required Terraform version constraint).
modules/gh-files-set/docs/header.md Module overview and usage snippet for terraform-docs injection.
modules/gh-files-set/docs/footer.md Footer content for terraform-docs injection (currently includes scaffolding/code fences).
modules/gh-files-set/README.md Generated/injected docs (currently out of sync with module interface/resources/outputs).
modules/gh-files-set/.terraform-docs.yml terraform-docs configuration for README generation.
modules/gh-files-set/_examples/basic/files.yaml Example input YAML (currently does not match the module input schema).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +81
| [github_repository_file.files](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_config"></a> [config](#input\_config) | Configuration for multiple GitHub repository files to be created/updated | <pre>object({<br/> files = list(object({<br/> branch = string<br/> commitMessage = string<br/> content = string<br/> file = string<br/> repository = string<br/> overwriteOnCreate = optional(bool, true)<br/> lifecycle = optional(any, {}) # placeholder for future extensions<br/> }))<br/> })</pre> | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_commit_messages"></a> [commit\_messages](#output\_commit\_messages) | Commit messages that were used |
| <a name="output_committed_files"></a> [committed\_files](#output\_committed\_files) | List of files that were successfully managed |
| <a name="output_file_paths"></a> [file\_paths](#output\_file\_paths) | Flat list of managed file paths (repo/path) |

### 5. `docs/footer.md`

```markdown
## Examples

See [_examples/basic](https://github.com/prefapp/tfm/tree/main/modules/gh-files-set/_examples/basic)

## Resources

- **github_repository_file**
https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file

## Support

Open issues in https://github.com/prefapp/tfm/issues
```
frmadem and others added 6 commits March 20, 2026 23:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Terraform module (modules/gh-files-set) intended to manage a set of files in a GitHub repository (issue #969), and wires it into the repo’s release-please module list.

Changes:

  • Added gh-files-set Terraform module (GitHub provider, variables/outputs, example, terraform-docs config, generated README).
  • Added module docs scaffolding (docs/header.md, docs/footer.md) and a basic YAML example.
  • Registered the module in release-please-config.json.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
release-please-config.json Registers modules/gh-files-set as a release-please package.
modules/gh-files-set/versions.tf Declares the GitHub provider requirement for the new module.
modules/gh-files-set/variables.tf Defines the module’s config schema and validations.
modules/gh-files-set/main.tf Implements managed vs “userManaged” GitHub repository file resources.
modules/gh-files-set/outputs.tf Exposes a list of “userManaged” file identifiers.
modules/gh-files-set/docs/header.md Module documentation header content for terraform-docs.
modules/gh-files-set/docs/footer.md Module documentation footer content for terraform-docs.
modules/gh-files-set/_examples/basic/files.yaml Provides a YAML example intended for yamldecode(...) input.
modules/gh-files-set/README.md Generated terraform-docs README for the module.
modules/gh-files-set/.terraform-docs.yml terraform-docs configuration for generating the module README.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@frmadem frmadem requested a review from alambike March 21, 2026 00:20
frmadem and others added 5 commits March 21, 2026 01:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +28
for_each = {
for f in var.config.files : "${f.file}/${f.branch}" => f
if f.userManaged
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ambiguous for_each key issue here ("${f.file}/${f.branch}"): branch names may contain '/', and file paths almost certainly do. This can cause key collisions and unexpected resource addressing. Prefer an unambiguous composite key (e.g., jsonencode([f.file, f.branch])).

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +16
data "github_repository" "this" {
full_name = var.config.repository
}

# Normal files — Terraform fully enforces content
resource "github_repository_file" "managed" {
for_each = {
for f in var.config.files : "${f.file}/${f.branch}" => f
if !f.userManaged
}

repository = data.github_repository.this.name
branch = each.value.branch
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.repository is validated as owner/repo, but the module ultimately passes only data.github_repository.this.name (repo name) to github_repository_file. This drops the owner portion and means the actual target owner will be whatever the GitHub provider is configured for. Either (a) change the input/validation/docs to accept a repo name only, or (b) adjust the implementation so the repository identifier used by github_repository_file matches what callers provide.

Copilot uses AI. Check for mistakes.
frmadem and others added 3 commits March 21, 2026 01:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POC gh files set

3 participants