Skip to content

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

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

feat: add new gh-files-set module#970
frmadem wants to merge 45 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.

@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.

frmadem and others added 5 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>
Comment on lines +23 to +39
# User-managed files — provision once + ignore content drift
resource "github_repository_file" "user_managed" {
for_each = {
for f in var.config.files : "${f.repository}/${f.file}/${f.branch}" => f
if f.userManaged
}

repository = data.github_repository.this.name
branch = each.value.branch
file = each.value.file
content = each.value.content
commit_message = each.value.commitMessage
overwrite_on_create = each.value.overwriteOnCreate

lifecycle {
ignore_changes = [content]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot how we could avoid user-managed files to be destroyed on terraform destroy, but without blocking the destroy process, that is, the terraform state should be destroyed without altering the file's contents, please implement it if you see a solution.

Copy link
Contributor

Copilot AI commented Mar 21, 2026

@alambike I've opened a new pull request, #1107, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Javier Gómez Rodríguez <javier.gomez@prefapp.es>
@frmadem
Copy link
Contributor Author

frmadem commented Mar 21, 2026

#970 (comment)

@alambike this problem is resolved by removing the files with a tofu state rm <address of the file's resource>.

The solution is working and has been tested.

https://github.com/prefapp/gitops-k8s/blob/2809a90c370f029ff9e0fcffd21c7250af752b30/packages/gh_provisioner/src/entities/ghfeature/index.ts#L58-L104

@frmadem
Copy link
Contributor Author

frmadem commented Mar 21, 2026

#970 (comment)

@alambike this problem is resolved by removing the files with a tofu state rm <address of the file's resource>.

The solution is working and has been tested.

https://github.com/prefapp/gitops-k8s/blob/2809a90c370f029ff9e0fcffd21c7250af752b30/packages/gh_provisioner/src/entities/ghfeature/index.ts#L58-L104

Besides the copilot solution seems to fail: https://github.com/jvazquez-prefapp/state-github/runs/68045393156?check_suite_focus=true

@frmadem frmadem requested a review from alambike March 22, 2026 14:43
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 1 comment.


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

Comment on lines +4 to +11
files = list(object({
branch = string
commitMessage = string
content = string
file = string
overwriteOnCreate = optional(bool, true)
userManaged = optional(bool, false)
}))
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The nested config.files object introduces camelCase attributes (commitMessage, overwriteOnCreate, userManaged). The rest of the repo’s Terraform module interfaces consistently use snake_case for variable and object attribute names (e.g., modules/aws-backup/variables.tf). Consider renaming these to snake_case for consistency (and to match github_repository_file arguments), or add a normalization layer if external tools require camelCase.

Copilot uses AI. Check for mistakes.
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

4 participants