Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
chanchiwai-ray committed Jun 3, 2024
1 parent 83aef57 commit 0fc4744
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/terraform-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
repository:
- hardware-observer-operator_main
- charmed-openstack-upgrader_main
- openstack-exporter-operator_main
# The snapcraft channel for 3.x is not ready
# - charmed-openstack-upgrader_3.x
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflow_files = {
release = {
source = "./files/github/snap_release.yaml"
destination = ".github/workflows/release.yaml"
variables = {
variables = {
branch = "3.x"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflow_files = {
release = {
source = "./files/github/snap_release.yaml"
destination = ".github/workflows/release.yaml"
variables = {
variables = {
branch = "main"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflow_files = {
release = {
source = "./files/github/charm_release.yaml"
destination = ".github/workflows/release.yaml"
variables = {
variables = {
branch = "main"
}
}
Expand Down
21 changes: 21 additions & 0 deletions terraform-plans/configs/openstack-exporter-operator_main.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repository = "openstack-exporter-operator"
branch = "main"
workflow_files = {
codeowners = {
source = "./files/github/CODEOWNERS"
destination = ".github/CODEOWNERS"
variables = {}
}
promote = {
source = "./files/github/charm_promote.yaml"
destination = ".github/workflows/promote.yaml"
variables = {}
}
release = {
source = "./files/github/charm_release.yaml"
destination = ".github/workflows/release.yaml"
variables = {
branch = "main"
}
}
}
8 changes: 4 additions & 4 deletions terraform-plans/modules/GitHub/workflows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "random_string" "update_uid" {
locals {
repo_files = flatten([
for file_key, file_info in var.workflow_files : {
file = file_info.destination
file = file_info.destination
source = file_info.source
}
])
Expand All @@ -44,15 +44,15 @@ data "github_repository_file" "files" {
locals {
repository_files_content = {
for file_key, file_info in var.workflow_files : file_info.destination =>
try(data.github_repository_file.files["${file_info.destination}"].content, "")
try(data.github_repository_file.files["${file_info.destination}"].content, "")
}
}

# Compare the fetched content with the local content to create a map of changed files
locals {
changed_files = {
for file_key, file_info in var.workflow_files : file_key => file_info
if templatefile(file_info.source, {vars = file_info.variables}) != local.repository_files_content[file_info.destination]
if templatefile(file_info.source, { vars = file_info.variables }) != local.repository_files_content[file_info.destination]
}
}

Expand All @@ -72,7 +72,7 @@ resource "github_repository_file" "workflows_files" {
repository = var.repository
branch = github_branch.workflows_branch[0].branch
file = each.value.destination
content = templatefile(each.value.source, {vars = each.value.variables})
content = templatefile(each.value.source, { vars = each.value.variables })
commit_message = "update ${each.value.destination}"
overwrite_on_create = true

Expand Down

0 comments on commit 0fc4744

Please sign in to comment.