From 2bf90c0489ef20e39848f0346b24bfb15a36c12f Mon Sep 17 00:00:00 2001 From: Ben Zarboni Date: Wed, 6 Mar 2024 09:20:00 -0500 Subject: [PATCH 1/2] Adds ability to create a README file for the org --- .../foundations-github-organization/repo_readme.tf | 12 ++++++++++++ modules/foundations-github-organization/variables.tf | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 modules/foundations-github-organization/repo_readme.tf diff --git a/modules/foundations-github-organization/repo_readme.tf b/modules/foundations-github-organization/repo_readme.tf new file mode 100644 index 0000000..7bc668c --- /dev/null +++ b/modules/foundations-github-organization/repo_readme.tf @@ -0,0 +1,12 @@ +data "file" "main_readme" { + filename = var.readme_path +} + +resource "github_repository_file" "main_readme" { + # Only create this when the readme filename is not empty + count = var.readme_path != "" ? 1 : 0 + repository = github_repository.organizations_repo.name + file = "README.md" + content = data.file.main_readme.content + depends_on = [github_repository.organizations_repo] +} \ No newline at end of file diff --git a/modules/foundations-github-organization/variables.tf b/modules/foundations-github-organization/variables.tf index f3f60e1..deb508f 100644 --- a/modules/foundations-github-organization/variables.tf +++ b/modules/foundations-github-organization/variables.tf @@ -52,4 +52,10 @@ variable "bucket_name" { variable "bucket_location" { type = string description = "The location of the tf state bucket." +} + +variable "readme_path" { + type = string + description = "Local Path to the README file in your current codebase. Pushed to the github foundation repository." + default = "" } \ No newline at end of file From 0be31de855ff53f2728c80d8d63c8ca9b035f174 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 6 Mar 2024 14:22:44 +0000 Subject: [PATCH 2/2] terraform-docs: automated action --- modules/foundations-github-organization/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/foundations-github-organization/README.md b/modules/foundations-github-organization/README.md index 864476c..7d8e5ef 100644 --- a/modules/foundations-github-organization/README.md +++ b/modules/foundations-github-organization/README.md @@ -9,6 +9,8 @@ | Name | Version | |------|---------| +| [file](#provider\_file) | n/a | +| [github](#provider\_github) | 5.44.0 | | [github.enterprise\_scoped](#provider\_github.enterprise\_scoped) | 5.44.0 | | [github.foundation\_org\_scoped](#provider\_github.foundation\_org\_scoped) | 5.44.0 | @@ -34,7 +36,9 @@ No modules. | [github_repository.organizations_repo](https://registry.terraform.io/providers/hashicorp/github/5.44.0/docs/resources/repository) | resource | | [github_repository_collaborators.bootstrap_repo_collaborators](https://registry.terraform.io/providers/hashicorp/github/5.44.0/docs/resources/repository_collaborators) | resource | | [github_repository_collaborators.organization_repo_collaborators](https://registry.terraform.io/providers/hashicorp/github/5.44.0/docs/resources/repository_collaborators) | resource | +| [github_repository_file.main_readme](https://registry.terraform.io/providers/hashicorp/github/5.44.0/docs/resources/repository_file) | resource | | [github_team.foundation_devs](https://registry.terraform.io/providers/hashicorp/github/5.44.0/docs/resources/team) | resource | +| [file_file.main_readme](https://registry.terraform.io/providers/hashicorp/file/latest/docs/data-sources/file) | data source | ## Inputs @@ -50,6 +54,7 @@ No modules. | [gcp\_tf\_state\_bucket\_project\_id](#input\_gcp\_tf\_state\_bucket\_project\_id) | The id of the gcp project where the tf state bucket was setup. | `string` | n/a | yes | | [github\_foundations\_organization\_name](#input\_github\_foundations\_organization\_name) | The name of the organization to create. | `string` | n/a | yes | | [organization\_workload\_identity\_sa](#input\_organization\_workload\_identity\_sa) | The service account to use for the organization repository oidc. | `string` | n/a | yes | +| [readme\_path](#input\_readme\_path) | Local Path to the README file in your current codebase. Pushed to the github foundation repository. | `string` | `""` | no | | [workload\_identity\_provider\_name](#input\_workload\_identity\_provider\_name) | The name of the workload identity provider to use for the oidc of the github foundation repositories. | `string` | n/a | yes | ## Outputs