From de8cb2aa4a116193524b4626151c5769f623ac31 Mon Sep 17 00:00:00 2001 From: Caner Derici Date: Fri, 29 Sep 2023 13:26:10 -0600 Subject: [PATCH] Pass controller variable through GITHUB_ENV --- .github/workflows/k8s_tunnel.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/k8s_tunnel.yml b/.github/workflows/k8s_tunnel.yml index e61a0104..f475f6b6 100644 --- a/.github/workflows/k8s_tunnel.yml +++ b/.github/workflows/k8s_tunnel.yml @@ -63,18 +63,13 @@ jobs: - name: "Set environment to configure provider" # language=bash run: | - CONTROLLER=$(juju whoami --format yaml | yq .controller) - - echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV + echo "CONTROLLER=$(juju whoami --format yaml | yq .controller)" >> $GITHUB_ENV echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV - echo "JUJU_CA_CERT<> $GITHUB_ENV - juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + echo "JUJU_CA_CERT=$(juju show-controller | yq .$CONTROLLER.details.ca-cert)" >> $GITHUB_ENV - run: go mod download - name: "Bring up loadbalancer & access via terraform plan" run: | - CONTROLLER=$(juju whoami --format yaml | yq .controller) # enable ingress and metallb to sudo microk8s enable ingress echo "Ingress enabled." @@ -97,7 +92,7 @@ jobs: echo "Juju Username : $JUJU_USERNAME" echo "Services layout:" - sudo microk8s.kubectl get services -n controller-$CONTROLLER controller-service + sudo microk8s.kubectl get services -n controller-$CONTROLLER # bring up the load balancer service sudo microk8s.kubectl apply -f - < ./terraform_config.tf - terraform init && terraform plan && terraform apply --auto-approve + # Initialize and apply Terraform + echo "Initializing Terraform..." + terraform init + echo "Planning Terraform changes..." + terraform plan + echo "Applying Terraform changes..." + terraform apply --auto-approve + + # Cleanup: Remove Terraform configuration file + # rm ./terraform_config.tf