Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Applying many github_repository_file resources results in #2438

Open
1 task done
Woody1193 opened this issue Oct 24, 2024 · 0 comments
Open
1 task done

[BUG]: Applying many github_repository_file resources results in #2438

Woody1193 opened this issue Oct 24, 2024 · 0 comments
Labels
Type: Bug Something isn't working as documented

Comments

@Woody1193
Copy link

Woody1193 commented Oct 24, 2024

Expected Behavior

I'm using this provider as a way to setup templated repositories for API services. As such, each Terraform apply attempts to commit a large number of files to a branch. When I apply this for a folder containing ~50 files, I expect all of them to be committed to the same branch and a PR to be created on that branch afterward.

Actual Behavior

I get the following error for a number of the files:

Error: POST https://api.github.com/repos/ElectroRoute-Japan/service-valuation/git/refs: 422 Reference already exists []

Re-running the terraform apply always results in a success so I know it's not an issue with the files themselves. It appears that I'm thrashing the GitHub API but I don't see an alternative here.

Terraform Version

Terraform v1.9.5
on linux_amd64

  • provider registry.terraform.io/integrations/github v6.3.1

Affected Resource(s)

  • github_repository_file

Terraform Configuration Files

resource "github_repository_file" "this" {
  for_each = local.src_files

  repository                      = var.repository
  file                            = replace(each.key, "service/", local.service_path)
  content                         = each.value
  branch                          = var.branch
  commit_message                  = "Created ${replace(each.key, "service/", local.service_path)}"
  autocreate_branch               = true
  autocreate_branch_source_branch = "main"
  overwrite_on_create             = false
}

resource "github_repository_pull_request" "this" {
  base_repository       = var.repository
  base_ref              = "main"
  head_ref              = var.branch
  title                 = "${local.proper_name} Service - Infrastructure"
  body                  = "This PR includes the standard API service infrastructure, customized for the ${local.proper_name} service. This was generated by Terraform."
  maintainer_can_modify = true
  depends_on            = [github_repository_file.this]
}

Steps to Reproduce

terraform init
terraform apply

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Woody1193 Woody1193 added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Oct 24, 2024
@kfcampbell kfcampbell moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Oct 25, 2024
@kfcampbell kfcampbell removed the Status: Triage This is being looked at and prioritized label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

2 participants