From 1982e2be43bd942c2a3a67a7661bfb3a70fe6d90 Mon Sep 17 00:00:00 2001 From: Orfeas Kourkakis Date: Mon, 9 Sep 2024 17:32:41 +0300 Subject: [PATCH] feat: Add reusable workflow to deploy terraform module --- .github/workflows/terraform-deploy.yaml | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/terraform-deploy.yaml diff --git a/.github/workflows/terraform-deploy.yaml b/.github/workflows/terraform-deploy.yaml new file mode 100644 index 0000000..b8726dd --- /dev/null +++ b/.github/workflows/terraform-deploy.yaml @@ -0,0 +1,62 @@ +name: Deploy Terraform module + +on: + workflow_call: + inputs: + working-directory: + description: The directory that stores the Terraform module. + required: false + type: string + default: ./terraform + model: + description: The model that the charm is deployed on. + required: false + type: string + default: kubeflow + channel: + description: The channel that the charm is deployed from. + required: false + type: string + default: latest/edge + workload-check: + description: If true, pass `-w` as an argument to juju-wait. This means it will wait for the unit to go to active. It defaults to false since most of kubeflow charms have other depenndencies required in order for them to be active. + required: false + type: boolean + default: false + +jobs: + deploy: + name: Deploy Terraform + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup operator environment + uses: charmed-kubernetes/actions-operator@main + with: + provider: microk8s + channel: 1.29-strict/stable + microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49" + juju-channel: 3.4/stable + charmcraft-channel: latest/candidate + - name: Install dependencies + run: | + sudo snap install --classic terraform + sudo snap install --classic juju-wait + - name: Apply terraform + run: | + # echo '{"credential": "microk8s", "enable-vault": true, "enable-barbican": true, "enable-designate": true, "nameservers": "testing.github."}' > terraform.tfvars.json + cd ${{ inputs.working-directory }} + terraform init + terraform apply -var "channel=${{ inputs.channel }}" -var "model_name=${{ inputs.model }}" --auto-approve + if [ "${{ inputs.workload-check }}" = false ]; then + juju-wait -v -m ${{ inputs.model }} -t 3600 + else + juju-wait -vw -m ${{ inputs.model }} -t 3600 + fi + + - name: Collect juju status + if: always() + run: | + juju status -m ${{ inputs.model }} + juju debug-log -m ${{ inputs.model }} --replay