Skip to content

Feature/gh conn stage #36

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/aks/github-connector/buildingblock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ No modules.
|------|------|
| [github_actions_environment_secret.container_registry](https://registry.terraform.io/providers/integrations/github/6.5.0/docs/resources/actions_environment_secret) | resource |
| [github_actions_environment_secret.kubeconfig](https://registry.terraform.io/providers/integrations/github/6.5.0/docs/resources/actions_environment_secret) | resource |
| [github_branch.branch](https://registry.terraform.io/providers/integrations/github/6.5.0/docs/resources/branch) | resource |
| [github_repository_environment.env](https://registry.terraform.io/providers/integrations/github/6.5.0/docs/resources/repository_environment) | resource |
| [github_repository_file.dockerfile](https://registry.terraform.io/providers/integrations/github/6.5.0/docs/resources/repository_file) | resource |
| [github_repository_file.workflow](https://registry.terraform.io/providers/integrations/github/6.5.0/docs/resources/repository_file) | resource |
Expand All @@ -64,7 +65,8 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_github_repo"></a> [github\_repo](#input\_github\_repo) | n/a | `string` | n/a | yes |
| <a name="input_github_branch"></a> [github\_branch](#input\_github\_branch) | The branch of the GitHub repository to be used. | `string` | n/a | yes |
| <a name="input_github_repo"></a> [github\_repo](#input\_github\_repo) | The GitHub repository to be connected. | `string` | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Associated namespace in AKS. | `string` | n/a | yes |

## Outputs
Expand Down
16 changes: 11 additions & 5 deletions modules/aks/github-connector/buildingblock/github.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ resource "github_actions_environment_secret" "container_registry" {
]
}

resource "github_branch" "branch" {
repository = var.github_repo
branch = var.github_branch
}

resource "github_repository_file" "dockerfile" {
repository = github_repository_environment.env.repository

file = "Dockerfile"
content = file("${path.module}/repo_content/Dockerfile")
branch = github_branch.branch.branch
file = "Dockerfile"
content = file("${path.module}/repo_content/Dockerfile")

commit_message = "Basic Dockerfile"
overwrite_on_create = true
Expand All @@ -73,15 +78,16 @@ resource "github_repository_file" "dockerfile" {

resource "github_repository_file" "workflow" {
repository = github_repository_environment.env.repository

file = ".github/workflows/${var.namespace}-deploy.yml"
branch = github_branch.branch.branch
file = ".github/workflows/${var.namespace}-deploy.yml"
content = templatefile(
"${path.module}/repo_content/workflow.yml",
{
namespace = var.namespace,
image_name = var.github_repo,
registry = local.acr.host
image_pull_secret = kubernetes_secret.image_pull.metadata[0].name
branch = github_branch.branch.branch
}
)

Expand Down
1 change: 0 additions & 1 deletion modules/aks/github-connector/buildingblock/provider.tf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ${namespace}
on:
push:
branches:
- main
- ${branch}

jobs:
deploy:
Expand Down
8 changes: 7 additions & 1 deletion modules/aks/github-connector/buildingblock/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ variable "namespace" {
}

variable "github_repo" {
type = string
description = "The GitHub repository to be connected."
type = string
}

variable "github_branch" {
description = "The branch of the GitHub repository to be used."
type = string
}
1 change: 1 addition & 0 deletions modules/github/repository/buildingblock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_auto_init"></a> [auto\_init](#input\_auto\_init) | Flag to indicate whether to create an initial commit with an empty README file | `bool` | `false` | no |
| <a name="input_repo_description"></a> [repo\_description](#input\_repo\_description) | Description of the GitHub repository | `string` | `"created by github-repo-building-block"` | no |
| <a name="input_repo_name"></a> [repo\_name](#input\_repo\_name) | Name of the GitHub repository | `string` | `"github-repo"` | no |
| <a name="input_repo_visibility"></a> [repo\_visibility](#input\_repo\_visibility) | Visibility of the GitHub repository | `string` | `"private"` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/github/repository/buildingblock/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "github_repository" "repository" {
name = var.repo_name
description = var.repo_description
visibility = var.repo_visibility
auto_init = false
auto_init = var.auto_init
vulnerability_alerts = true
archive_on_destroy = true

Expand Down
6 changes: 6 additions & 0 deletions modules/github/repository/buildingblock/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ variable "use_template" {
description = "Flag to indicate whether to create a repo based on a Template Repository"
default = false
}

variable "auto_init" {
type = bool
description = "Flag to indicate whether to create an initial commit with an empty README file"
default = false
}
Loading