diff --git a/README.md b/README.md
index 0a5d81b..c0e90cc 100644
--- a/README.md
+++ b/README.md
@@ -365,7 +365,6 @@ No modules.
|------|-------------|
| [default\_branch](#output\_default\_branch) | Default branch of the repository |
| [full\_name](#output\_full\_name) | Full name of the repository in org/repo format |
-| [generated\_deploy\_keys](#output\_generated\_deploy\_keys) | Generated private keys for deploy keys with create=true |
| [git\_clone\_url](#output\_git\_clone\_url) | URL that can be provided to git clone to clone the repository anonymously via the git protocol |
| [github\_repo](#output\_github\_repo) | All attributes of the GitHub repository |
| [html\_url](#output\_html\_url) | URL to the repository on GitHub |
diff --git a/github_files.tf b/github_files.tf
index e526711..37aacbf 100644
--- a/github_files.tf
+++ b/github_files.tf
@@ -45,12 +45,12 @@ data "github_ref" "ref" {
locals {
extra_files = concat(
var.extra_files,
- local.lookup_sha == 1 && length(data.github_ref.ref) > 0 && length(data.github_ref.ref) == 0 ? [] : [
+ local.lookup_sha == 1 ? [
{
path = ".TEMPLATE_SHA",
content = local.lookup_sha == 1 && length(data.github_ref.ref) > 0 ? data.github_ref.ref[0].sha : ""
}
- ]
+ ] : []
)
repository_name = var.create_repo ? local.github_repo.name : var.name
}
diff --git a/github_repo.tf b/github_repo.tf
index 514adff..8243f9b 100644
--- a/github_repo.tf
+++ b/github_repo.tf
@@ -1,7 +1,10 @@
locals {
repo_name = var.force_name ? var.name : "${var.name}-${formatdate("YYYYMMDD", timestamp())}"
- github_repo = var.create_repo ? github_repository.repo[0] : data.github_repository.existing[0]
+ # Safe access to repo and existing resources
+ github_repo = var.create_repo && length(github_repository.repo) > 0 ? github_repository.repo[0] : (
+ length(data.github_repository.existing) > 0 ? data.github_repository.existing[0] : null
+ )
validate_merge_options = (
var.github_allow_merge_commit ||